+ adding releases, better fd management

This commit is contained in:
Dominika 2021-12-20 02:46:04 +01:00
parent b6a3652474
commit 9b1950dfb2

32
main.py
View file

@ -77,8 +77,17 @@ class Passthrough(Operations):
print("-- getattr", full_path) print("-- getattr", full_path)
if full_path.split('/')[-2] in assets or len(full_path.split('/')) == 2: if full_path.split('/')[-2] in assets or len(full_path.split('/')) == 2:
if len(full_path.split('/')) < 3: # TODO: making new releases if len(full_path.split('/')) < 3: # TODO: making new releases
st_mode = 0o40744 if full_path == 'b/':
st_size = 1337 st_mode = 0o40744
st_size = 1337
else:
if any((full_path.split('/')[1] == r["name"] for r in releases)):
st_mode = 0o40744
st_size = 1337
else:
raise FuseOSError(2)
st_mode = 0o700000
st_size = 0
else: else:
st_mode = 0o100744 st_mode = 0o100744
print(full_path.split('/')) print(full_path.split('/'))
@ -142,8 +151,13 @@ class Passthrough(Operations):
return os.rmdir(full_path) return os.rmdir(full_path)
def mkdir(self, path, mode): def mkdir(self, path, mode):
print("-- mkdir") print("-- mkdir", path)
return os.mkdir(self._full_path(path), mode) #return os.mkdir(self._full_path(path), mode)
a = requests.post("https://api.github.com/repos/DomiOwO/" + repo + "/releases",
headers = headers,
data = '{"tag_name":"'+path.split("/")[1]+'"}')
print(a.content)
return 0
def statfs(self, path): def statfs(self, path):
full_path = self._full_path(path) full_path = self._full_path(path)
@ -156,8 +170,10 @@ class Passthrough(Operations):
def unlink(self, path): def unlink(self, path):
print("-- unlink") print("-- unlink")
global assets global assets
_h = headers
_h["Accept"] = "application/json"
a = requests.delete("https://api.github.com/repos/DomiOwO/" + repo + "/releases/assets/" + str(assets[path.split("/")[-2]][path.split("/")[-1]]["id"]), a = requests.delete("https://api.github.com/repos/DomiOwO/" + repo + "/releases/assets/" + str(assets[path.split("/")[-2]][path.split("/")[-1]]["id"]),
headers = headers) headers = _h)
print(a.content) print(a.content)
del(assets[path.split('/')[-2]][path.split('/')[-1]]) del(assets[path.split('/')[-2]][path.split('/')[-1]])
return 0 return 0
@ -210,7 +226,7 @@ class Passthrough(Operations):
f = fileByFd(fh) f = fileByFd(fh)
f["state"] = 1 f["state"] = 1
f["buffer"] += buf f["buffer"] += buf
return 0 return len(buf)
def truncate(self, path, length, fh=None): def truncate(self, path, length, fh=None):
print("-- truncate") print("-- truncate")
@ -237,8 +253,10 @@ class Passthrough(Operations):
data = f["buffer"], data = f["buffer"],
headers = _h) headers = _h)
print(a.content) print(a.content)
res = a.json()
assets[path.split('/')[-2]][path.split('/')[-1]] = {"id": res["id"], "size": res["size"]}
del (files[fileByFd(fh)["fd"]]) # idk, bad syntax?
return 0 return 0
#del(files[fileByFd(fh)])
def fsync(self, path, fdatasync, fh): def fsync(self, path, fdatasync, fh):
print("-- fsync") print("-- fsync")