Skip to content

Commit abb32a0

Browse files
hilludavide125
authored andcommitted
Fix breakage when using local resources
The URL cache is only used in the (common) case where the installation zip archive is downloaded using http/https. Signed-off-by: Hilko Bengen <[email protected]>
1 parent 476e3b8 commit abb32a0

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/util.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ def fdcopy(self, sfd, dfd, size=None):
203203
copied = 0
204204
bps = 0
205205
st = time.time()
206-
self.ucache.bytes_read = 0
206+
if self.ucache:
207+
self.ucache.bytes_read = 0
207208
while True:
208209
if size is not None and size != 0:
209210
prog = copied / size * 100
@@ -215,7 +216,8 @@ def fdcopy(self, sfd, dfd, size=None):
215216
break
216217
dfd.write(d)
217218
copied += len(d)
218-
bps = self.ucache.bytes_read / (time.time() - st)
219+
if self.ucache:
220+
bps = self.ucache.bytes_read / (time.time() - st)
219221

220222
if size is not None:
221223
sys.stdout.write("\033[3G100.00% ")
@@ -247,16 +249,19 @@ def stream_compress(self, istream, size, path, crc=None, sha1=None):
247249
scratch = bytes(lzfse.compression_encode_scratch_buffer_size(COMPRESSION_LZFSE))
248250
outbuf = bytes(CHUNK_SIZE)
249251
st = time.time()
250-
self.ucache.bytes_read = 0
252+
if self.ucache:
253+
self.ucache.bytes_read = 0
251254
copied = 0
255+
bps = 0
252256
with open(path + '/..namedfork/rsrc', 'wb') as res_fork:
253257
res_fork.write(b'\0' * cur_pos)
254258
for i in range(num_chunks):
255259
table.append(cur_pos)
256260
inbuf = istream.read(CHUNK_SIZE)
257261
copied += len(inbuf)
258262
prog = copied / size * 100
259-
bps = self.ucache.bytes_read / (time.time() - st)
263+
if self.ucache:
264+
bps = self.ucache.bytes_read / (time.time() - st)
260265
sys.stdout.write(f"\033[3G{prog:6.2f}% ({ssize(bps)}/s)")
261266
sys.stdout.flush()
262267
self.printed_progress = True

0 commit comments

Comments
 (0)