* shitty upload
parent
b193967e50
commit
940030ed7b
24
main.py
24
main.py
|
@ -11,12 +11,12 @@ from fuse import FUSE, FuseOSError, Operations, fuse_get_context
|
||||||
releases = []
|
releases = []
|
||||||
assets = {}
|
assets = {}
|
||||||
headers = {"Authorization":"token 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"}
|
headers = {"Authorization":"token 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"}
|
||||||
repo = "owosoftware"
|
repo = "iwisoftware"
|
||||||
files=[{"fd":0}]
|
files=[{"fd":0}]
|
||||||
|
|
||||||
def getReleases():
|
def getReleases():
|
||||||
if not releases:
|
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()
|
x=a.json()
|
||||||
for i in x:
|
for i in x:
|
||||||
releases.extend([{"name":i["tag_name"], "id":i["id"]}])
|
releases.extend([{"name":i["tag_name"], "id":i["id"]}])
|
||||||
|
@ -84,9 +84,9 @@ class Passthrough(Operations):
|
||||||
st_mode = 0o100000
|
st_mode = 0o100000
|
||||||
st_size = 0
|
st_size = 0
|
||||||
else:
|
else:
|
||||||
st_mode = 0o0
|
st_mode = 0o100000
|
||||||
st_size = 0
|
st_size = 0
|
||||||
|
print(st_mode, st_size)
|
||||||
return {'st_atime': 1,
|
return {'st_atime': 1,
|
||||||
'st_ctime': 1,
|
'st_ctime': 1,
|
||||||
'st_gid': 1000,
|
'st_gid': 1000,
|
||||||
|
@ -189,12 +189,24 @@ class Passthrough(Operations):
|
||||||
_h = headers
|
_h = headers
|
||||||
_h["Range"] = "bytes=" + str(len(f["buffer"])) + "-" + str(len(f["buffer"]) + 10485760) # 5MB
|
_h["Range"] = "bytes=" + str(len(f["buffer"])) + "-" + str(len(f["buffer"]) + 10485760) # 5MB
|
||||||
_h["Accept"] = "application/octet-stream"
|
_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
|
f["buffer"] += a.content
|
||||||
return f["buffer"][offset:offset+length]
|
return f["buffer"][offset:offset+length]
|
||||||
|
|
||||||
def write(self, path, buf, offset, fh):
|
def write(self, path, buf, offset, fh):
|
||||||
print("-- write: offset ", offset, " buf ", buf, " path ", path)
|
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
|
return 0
|
||||||
|
|
||||||
def truncate(self, path, length, fh=None):
|
def truncate(self, path, length, fh=None):
|
||||||
|
@ -207,7 +219,7 @@ class Passthrough(Operations):
|
||||||
|
|
||||||
def release(self, path, fh):
|
def release(self, path, fh):
|
||||||
print("-- release/close")
|
print("-- release/close")
|
||||||
del(files[fileByFd(fh)])
|
#del(files[fileByFd(fh)])
|
||||||
|
|
||||||
def fsync(self, path, fdatasync, fh):
|
def fsync(self, path, fdatasync, fh):
|
||||||
print("-- fsync")
|
print("-- fsync")
|
||||||
|
|
Loading…
Reference in New Issue