* fixed bugs
This commit is contained in:
parent
dfe6c493de
commit
3d8323e8ef
32
main.py
32
main.py
|
@ -14,12 +14,12 @@ headers = {"Authorization": "token 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",
|
||||||
"Accept": "application/json"}
|
"Accept": "application/json"}
|
||||||
user = "DomiOwO"
|
user = "DomiOwO"
|
||||||
repo = "iwisoftware"
|
repo = "iwisoftware"
|
||||||
files=[{}]
|
files=[{}] # offsetting by 1 because FD 0 is invalid
|
||||||
files_buffers=[[]]
|
files_buffers=[[]]
|
||||||
|
|
||||||
def getReleases():
|
def getReleases():
|
||||||
if not releases:
|
if not releases:
|
||||||
a=requests.get("https://api.github.com/repos/"+ user +"/" + repo + "/releases", headers = headers);
|
a=requests.get("https://api.github.com/repos/"+ user + "/" + 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"]}])
|
||||||
|
@ -81,8 +81,7 @@ class Passthrough(Operations):
|
||||||
if full_path.split('/')[-1] in assets[full_path.split('/')[-2]]:
|
if full_path.split('/')[-1] in assets[full_path.split('/')[-2]]:
|
||||||
st_size = assets[full_path.split('/')[-2]][full_path.split('/')[-1]]["size"]
|
st_size = assets[full_path.split('/')[-2]][full_path.split('/')[-1]]["size"]
|
||||||
else:
|
else:
|
||||||
st_mode = 0o100000
|
raise FuseOSError(2)
|
||||||
st_size = 0
|
|
||||||
else:
|
else:
|
||||||
st_mode = 0o100000
|
st_mode = 0o100000
|
||||||
st_size = 0
|
st_size = 0
|
||||||
|
@ -142,21 +141,21 @@ class Passthrough(Operations):
|
||||||
if releases[i]["name"] == path.split("/")[1]:
|
if releases[i]["name"] == path.split("/")[1]:
|
||||||
a = requests.delete("https://api.github.com/repos/" + user + "/" + repo + "/releases/" + str(releases[i]["id"]),
|
a = requests.delete("https://api.github.com/repos/" + user + "/" + repo + "/releases/" + str(releases[i]["id"]),
|
||||||
headers = _h)
|
headers = _h)
|
||||||
assets[releases[i]["name"]] = {}
|
del(assets[releases[i]["name"]])
|
||||||
del(releases[i])
|
del(releases[i])
|
||||||
print(a.content)
|
print(a.content)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def mkdir(self, path, mode):
|
def mkdir(self, path, mode):
|
||||||
print("-- mkdir", path)
|
print("-- mkdir", path)
|
||||||
global releases
|
global releases, assets
|
||||||
a = requests.post("https://api.github.com/repos/" + user + "/" + repo + "/releases",
|
a = requests.post("https://api.github.com/repos/" + user + "/" + repo + "/releases",
|
||||||
headers = headers,
|
headers = headers,
|
||||||
data = '{"tag_name":"'+path.split("/")[1]+'"}')
|
data = '{"tag_name":"'+path.split("/")[1]+'"}')
|
||||||
print(a.content)
|
print(a.content)
|
||||||
x = a.json()
|
x = a.json()
|
||||||
releases+=[{"name":path.split("/")[1], "id": x["id"]}]
|
releases.extend([{"name": path.split("/")[1], "id": x["id"]}])
|
||||||
assets[path.split('/')[-2]]={}
|
assets[path.split('/')[1]] = {}
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def statfs(self, path):
|
def statfs(self, path):
|
||||||
|
@ -204,6 +203,7 @@ class Passthrough(Operations):
|
||||||
|
|
||||||
def create(self, path, mode, fi=None):
|
def create(self, path, mode, fi=None):
|
||||||
print("-- create")
|
print("-- create")
|
||||||
|
assets[path.split('/')[-2]][path.split('/')[-1]] = {"id": -1, "size": 0}
|
||||||
return allocateFd(path)
|
return allocateFd(path)
|
||||||
|
|
||||||
def read(self, path, length, offset, fh):
|
def read(self, path, length, offset, fh):
|
||||||
|
@ -222,9 +222,12 @@ class Passthrough(Operations):
|
||||||
_h["Range"] = "bytes=" + str(f["len"]) + "-" + str(f["len"] + fetch_len - 1)
|
_h["Range"] = "bytes=" + str(f["len"]) + "-" + str(f["len"] + fetch_len - 1)
|
||||||
f["len"] += fetch_len
|
f["len"] += fetch_len
|
||||||
_h["Accept"] = "application/octet-stream"
|
_h["Accept"] = "application/octet-stream"
|
||||||
a = requests.get("https://api.github.com/repos/" + user + "/" + repo + "/releases/assets/" + str(assets[path.split("/")[-2]][path.split("/")[-1]]["id"]),
|
try:
|
||||||
|
a = requests.get("https://api.github.com/repos/" + user + "/" + repo + "/releases/assets/" + str(assets[path.split("/")[-2]][path.split("/")[-1]]["id"]),
|
||||||
headers = _h);
|
headers = _h);
|
||||||
files_buffers[fh].append(bytes(a.content))
|
files_buffers[fh].append(bytes(a.content))
|
||||||
|
except:
|
||||||
|
raise FuseOSError(2) # idk, lets fix getattr sometime
|
||||||
return b''.join(files_buffers[fh])[offset:offset+length]
|
return b''.join(files_buffers[fh])[offset:offset+length]
|
||||||
|
|
||||||
def write(self, path, buf, offset, fh):
|
def write(self, path, buf, offset, fh):
|
||||||
|
@ -247,7 +250,7 @@ class Passthrough(Operations):
|
||||||
f = files[fh]
|
f = files[fh]
|
||||||
if(f["state"] == 1):
|
if(f["state"] == 1):
|
||||||
_h = headers
|
_h = headers
|
||||||
_h["Content-Type"] = "application/octet-stream"
|
_h["Content-Type"] = "application/json"
|
||||||
for i in releases: # move this into a function?
|
for i in releases: # move this into a function?
|
||||||
if i["name"] == path.split('/')[-2]:
|
if i["name"] == path.split('/')[-2]:
|
||||||
id = i["id"]
|
id = i["id"]
|
||||||
|
@ -260,10 +263,9 @@ class Passthrough(Operations):
|
||||||
headers = _h)
|
headers = _h)
|
||||||
print(a.content)
|
print(a.content)
|
||||||
res = a.json()
|
res = a.json()
|
||||||
print(assets[path.split('/')[-2]])
|
print(assets)
|
||||||
if not assets[path.split('/')[-2]]:
|
#if not assets[path.split('/')[-2]]:
|
||||||
assets[path.split('/')[-2]]={}
|
# assets[path.split('/')[-2]] = [{}]
|
||||||
print(assets[path.split('/')[-2]])
|
|
||||||
assets[path.split('/')[-2]][path.split('/')[-1]] = {"id": res["id"], "size": res["size"]}
|
assets[path.split('/')[-2]][path.split('/')[-1]] = {"id": res["id"], "size": res["size"]}
|
||||||
del(files[fh]) # idk, bad syntax?
|
del(files[fh]) # idk, bad syntax?
|
||||||
del(files_buffers[fh])
|
del(files_buffers[fh])
|
||||||
|
|
Loading…
Reference in a new issue