Skip to content

Commit

Permalink
Fix breakage when using local resources
Browse files Browse the repository at this point in the history
The URL cache is only used in the (common) case where the installation
zip archive is downloaded using http/https.
  • Loading branch information
hillu committed Jun 14, 2024
1 parent e83274b commit 43c3de4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ def fdcopy(self, sfd, dfd, size=None):
copied = 0
bps = 0
st = time.time()
self.ucache.bytes_read = 0
if self.ucache:
self.ucache.bytes_read = 0
while True:
if size is not None:
prog = copied / size * 100
Expand All @@ -213,7 +214,8 @@ def fdcopy(self, sfd, dfd, size=None):
break
dfd.write(d)
copied += len(d)
bps = self.ucache.bytes_read / (time.time() - st)
if self.ucache:
bps = self.ucache.bytes_read / (time.time() - st)

if size is not None:
sys.stdout.write("\033[3G100.00% ")
Expand Down Expand Up @@ -245,16 +247,19 @@ def stream_compress(self, istream, size, path, crc=None, sha1=None):
scratch = bytes(lzfse.compression_encode_scratch_buffer_size(COMPRESSION_LZFSE))
outbuf = bytes(CHUNK_SIZE)
st = time.time()
self.ucache.bytes_read = 0
if self.ucache:
self.ucache.bytes_read = 0
copied = 0
bps = 0
with open(path + '/..namedfork/rsrc', 'wb') as res_fork:
res_fork.write(b'\0' * cur_pos)
for i in range(num_chunks):
table.append(cur_pos)
inbuf = istream.read(CHUNK_SIZE)
copied += len(inbuf)
prog = copied / size * 100
bps = self.ucache.bytes_read / (time.time() - st)
if self.ucache:
bps = self.ucache.bytes_read / (time.time() - st)
sys.stdout.write(f"\033[3G{prog:6.2f}% ({ssize(bps)}/s)")
sys.stdout.flush()
self.printed_progress = True
Expand Down

0 comments on commit 43c3de4

Please sign in to comment.