Commit 1b88590d authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: Downloaded archive file removed before re-downloading if checksums don't

match. Error messages on assertion checks.
parent 104b1b8c
......@@ -132,8 +132,10 @@ def downloadFile(url : Union[str, pathlib.Path],
destination = op.abspath(destination)
assert not op.exists(destination)
assert admin.canWrite(op.dirname(destination))
assert not op.exists(destination), \
f'{destination} already exists!'
assert admin.canWrite(op.dirname(destination)), \
f'Cannot write to {destination}!'
# all files are saved to a temporary location
# alongside the final destination. If a download
......@@ -187,9 +189,9 @@ def calcChecksum(path : Union[str, pathlib.Path],
:returns: String containing a SHA256 checksum
"""
assert op.exists(path)
assert op.isfile(path)
assert blockSize > 0
assert op.exists(path), f'{path} does not exist!'
assert op.isfile(path), f'{path} is not a file!'
assert blockSize > 0, f'blockSize must be >0 ({blockSize})!'
hashobj = hashlib.sha256()
......@@ -241,11 +243,11 @@ def _extractArchive(archiveFile : Union[str, pathlib.Path],
supported.
"""
assert op.exists( archiveFile)
assert op.isfile( archiveFile)
assert op.exists( destination)
assert op.isdir( destination)
assert admin.canWrite(destination)
assert op.exists( archiveFile), f'{archiveFile} does not exist!'
assert op.isfile( archiveFile), f'{archiveFile} is not a file!'
assert op.exists( destination), f'{destination} does not exist!'
assert op.isdir( destination), f'{destination} is not a directory!'
assert admin.canWrite(destination), f'Cannot write to {destination}!'
try:
shutil.unpack_archive(archiveFile, destination)
......
......@@ -327,6 +327,7 @@ def downloadPlugin(plugin : Plugin, destDir, **kwargs) -> Tuple[str, bool]:
info('Checksums do not match - re-downloading file')
info(f' manifest checksum: {plugin.checksum}')
info(f' existing file checksum: {destchecksum}')
os.remove(destFile)
if not skipDownload:
info(f'Downloading {plugin.url}')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment