Skip to content

Commit

Permalink
fix issue in file remove
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-roelofs committed May 2, 2017
1 parent 94c3982 commit a33cfd5
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions src/FunKiiUmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,30 +400,27 @@ def start(self):
self.log('Total size is {}\n'.format(bytes2human(total_size)))

for i in range(content_count):
if not self.run:
c_offs = 0xB04 + (0x30 * i)
c_id = binascii.hexlify(tmd[c_offs:c_offs + 0x04]).decode()
c_type = binascii.hexlify(tmd[c_offs + 0x06:c_offs + 0x8])
expected_size = int(binascii.hexlify(
tmd[c_offs + 0x08:c_offs + 0x10]), 16)
self.log('Downloading {} of {} for {}.'.format(i + 1, content_count,dirname))
outfname = os.path.join(rawdir, c_id + '.app')
outfnameh3 = os.path.join(rawdir, c_id + '.h3')

if not self.download_file('{}/{}'.format(baseurl, c_id), outfname, self.retry_count, expected_size=expected_size):
self.log('ERROR: Could not download content file... Skipping title')
shutil.rmtree(rawdir, ignore_errors=True)
return
else:
c_offs = 0xB04 + (0x30 * i)
c_id = binascii.hexlify(tmd[c_offs:c_offs + 0x04]).decode()
c_type = binascii.hexlify(tmd[c_offs + 0x06:c_offs + 0x8])
expected_size = int(binascii.hexlify(
tmd[c_offs + 0x08:c_offs + 0x10]), 16)
self.log('Downloading {} of {} for {}.'.format(i + 1, content_count,dirname))
outfname = os.path.join(rawdir, c_id + '.app')
outfnameh3 = os.path.join(rawdir, c_id + '.h3')

if not self.download_file('{}/{}'.format(baseurl, c_id), outfname, self.retry_count, expected_size=expected_size):
self.log('ERROR: Could not download content file... Skipping title')
shutil.rmtree(rawdir, ignore_errors=True)
return
if not self.download_file('{}/{}.h3'.format(baseurl, c_id), outfnameh3, self.retry_count, ignore_404=True):
self.log('ERROR: Could not download h3 file... Skipping title')
shutil.rmtree(rawdir, ignore_errors=True)
return

self.percent = str(int((float(i + 1) / float(content_count))*100)) + "%"
if self.percentcallback != "":
self.percentcallback()
if not self.download_file('{}/{}.h3'.format(baseurl, c_id), outfnameh3, self.retry_count, ignore_404=True):
self.log('ERROR: Could not download h3 file... Skipping title')
shutil.rmtree(rawdir, ignore_errors=True)
return

self.percent = str(int((float(i + 1) / float(content_count))*100)) + "%"
if self.percentcallback != "":
self.percentcallback()

self.log('Title download complete in "{}"\n'.format(dirname))

Expand Down

0 comments on commit a33cfd5

Please sign in to comment.