+ shitty download buffering
parent
1a38f00be7
commit
5ef61aad02
21
main.py
21
main.py
|
@ -13,6 +13,9 @@ assets = {}
|
||||||
headers = {"Authorization":"token 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"}
|
headers = {"Authorization":"token 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"}
|
||||||
repo = "owosoftware"
|
repo = "owosoftware"
|
||||||
offset_temp = 0 # TODO
|
offset_temp = 0 # TODO
|
||||||
|
buffer_len = 0 # TODO
|
||||||
|
global buffer;
|
||||||
|
buffer = b""
|
||||||
|
|
||||||
def getReleases():
|
def getReleases():
|
||||||
if not releases:
|
if not releases:
|
||||||
|
@ -174,16 +177,20 @@ class Passthrough(Operations):
|
||||||
return random.randrange(1,100)
|
return random.randrange(1,100)
|
||||||
|
|
||||||
def read(self, path, length, offset, fh):
|
def read(self, path, length, offset, fh):
|
||||||
|
global buffer
|
||||||
|
global buffer_len
|
||||||
print("-- read: offset ", offset, " len ", length, " path ", path)
|
print("-- read: offset ", offset, " len ", length, " path ", path)
|
||||||
l = length + offset_temp
|
if offset + length > buffer_len:
|
||||||
_h = headers
|
print("buffer exhausted: ", buffer_len)
|
||||||
_h["Range"] = "bytes=" + str(offset_temp) + "-" + str(l-1)
|
_h = headers
|
||||||
_h["Accept"] = "application/octet-stream"
|
_h["Range"] = "bytes=" + str(buffer_len) + "-" + str(buffer_len + 10485760) # 5MB
|
||||||
a = requests.get("https://api.github.com/repos/DomiOwO/" + repo + "/releases/assets/" + str(assets[path.split("/")[-2]][path.split("/")[-1]]["id"]), headers=headers);
|
_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);
|
||||||
|
buffer += a.content
|
||||||
|
buffer_len = buffer_len + 10485760
|
||||||
#os.lseek(fh, offset, os.SEEK_SET)
|
#os.lseek(fh, offset, os.SEEK_SET)
|
||||||
#return os.read(fh, length)
|
#return os.read(fh, length)
|
||||||
offset_ = offset_temp + offset
|
return buffer[offset:offset+length]
|
||||||
return a.content
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue