+ very slow download of files

This commit is contained in:
Dominika 2021-12-16 01:49:33 +01:00
parent c0aa9ae4e7
commit 1a38f00be7
2 changed files with 13 additions and 5 deletions

16
main.py
View file

@ -12,6 +12,7 @@ releases = []
assets = {}
headers = {"Authorization":"token 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"}
repo = "owosoftware"
offset_temp = 0 # TODO
def getReleases():
if not releases:
@ -57,7 +58,7 @@ class Passthrough(Operations):
full_path = self._full_path(path)
print("-- getattr", full_path)
if full_path.split('/')[-2] in assets or len(full_path.split('/')) == 2:
if len(full_path.split('/')) < 3:
if len(full_path.split('/')) < 3: # TODO: making new releases
st_mode = 0o40744
st_size = 1337
else:
@ -73,8 +74,8 @@ class Passthrough(Operations):
st_mode = 0o0
st_size = 0
return {'st_atime': 1639567402.302016,
'st_ctime': 1625937692.4645624,
return {'st_atime': 1,
'st_ctime': 1,
'st_gid': 1000,
'st_mode': int(st_mode),
'st_mtime': 1625937692.4645624,
@ -174,9 +175,15 @@ class Passthrough(Operations):
def read(self, path, length, offset, fh):
print("-- read: offset ", offset, " len ", length, " path ", path)
l = length + offset_temp
_h = headers
_h["Range"] = "bytes=" + str(offset_temp) + "-" + str(l-1)
_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);
#os.lseek(fh, offset, os.SEEK_SET)
#return os.read(fh, length)
return b"maeiscute"
offset_ = offset_temp + offset
return a.content
def write(self, path, buf, offset, fh):
print("-- write: offset ", offset, " buf ", buf, " path ", path)
@ -199,6 +206,7 @@ class Passthrough(Operations):
def release(self, path, fh):
print("-- release/close")
_offset = 0
#return os.close(fh)
def fsync(self, path, fdatasync, fh):

View file

@ -1,2 +1,2 @@
fusepy
requests
requests