From 940030ed7b2da573869c04593a2d110a101c5710 Mon Sep 17 00:00:00 2001 From: Dominika Liberda Date: Fri, 17 Dec 2021 18:30:06 +0100 Subject: [PATCH] * shitty upload --- main.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 2ee7ab7..07d1ab5 100755 --- a/main.py +++ b/main.py @@ -11,12 +11,12 @@ from fuse import FUSE, FuseOSError, Operations, fuse_get_context releases = [] assets = {} headers = {"Authorization":"token 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"} -repo = "owosoftware" +repo = "iwisoftware" files=[{"fd":0}] def getReleases(): if not releases: - a=requests.get("https://api.github.com/repos/DomiOwO/"+repo+"/releases", headers=headers); + a=requests.get("https://api.github.com/repos/DomiOwO/" + repo + "/releases", headers=headers); x=a.json() for i in x: releases.extend([{"name":i["tag_name"], "id":i["id"]}]) @@ -84,9 +84,9 @@ class Passthrough(Operations): st_mode = 0o100000 st_size = 0 else: - st_mode = 0o0 + st_mode = 0o100000 st_size = 0 - + print(st_mode, st_size) return {'st_atime': 1, 'st_ctime': 1, 'st_gid': 1000, @@ -189,12 +189,24 @@ class Passthrough(Operations): _h = headers _h["Range"] = "bytes=" + str(len(f["buffer"])) + "-" + str(len(f["buffer"]) + 10485760) # 5MB _h["Accept"] = "application/octet-stream" - a = requests.get("https://api.github.com/repos/DomiOwO/" + repo + "/releases/assets/" + str(assets[path.split("/")[-2]][path.split("/")[-1]]["id"]), headers=headers); + a = requests.get("https://api.github.com/repos/DomiOwO/" + repo + "/releases/assets/" + str(assets[path.split("/")[-2]][path.split("/")[-1]]["id"]), + headers = _h); f["buffer"] += a.content return f["buffer"][offset:offset+length] def write(self, path, buf, offset, fh): print("-- write: offset ", offset, " buf ", buf, " path ", path) + _h = headers + _h["Content-Type"] = "application/octet-stream" + for i in releases: + if i["name"] == path.split('/')[-2]: + id = i["id"] + break + + a = requests.post("https://uploads.github.com/repos/DomiOwO/" + repo + "/releases/" + str(id) + "/assets?name=" + path.split('/')[-1], + data = buf, + headers = _h) + print(a.content) return 0 def truncate(self, path, length, fh=None): @@ -207,7 +219,7 @@ class Passthrough(Operations): def release(self, path, fh): print("-- release/close") - del(files[fileByFd(fh)]) + #del(files[fileByFd(fh)]) def fsync(self, path, fdatasync, fh): print("-- fsync")