diff --git a/main.py b/main.py index dcb050c..441b9dc 100755 --- a/main.py +++ b/main.py @@ -77,8 +77,17 @@ class Passthrough(Operations): print("-- getattr", full_path) if full_path.split('/')[-2] in assets or len(full_path.split('/')) == 2: if len(full_path.split('/')) < 3: # TODO: making new releases - st_mode = 0o40744 - st_size = 1337 + if full_path == 'b/': + 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: st_mode = 0o100744 print(full_path.split('/')) @@ -142,8 +151,13 @@ class Passthrough(Operations): return os.rmdir(full_path) def mkdir(self, path, mode): - print("-- mkdir") - return os.mkdir(self._full_path(path), mode) + print("-- mkdir", path) + #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): full_path = self._full_path(path) @@ -156,8 +170,10 @@ class Passthrough(Operations): def unlink(self, path): print("-- unlink") 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"]), - headers = headers) + headers = _h) print(a.content) del(assets[path.split('/')[-2]][path.split('/')[-1]]) return 0 @@ -210,7 +226,7 @@ class Passthrough(Operations): f = fileByFd(fh) f["state"] = 1 f["buffer"] += buf - return 0 + return len(buf) def truncate(self, path, length, fh=None): print("-- truncate") @@ -237,8 +253,10 @@ class Passthrough(Operations): data = f["buffer"], headers = _h) 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 - #del(files[fileByFd(fh)]) def fsync(self, path, fdatasync, fh): print("-- fsync")