Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
add_module
Commits
1b88590d
Commit
1b88590d
authored
Oct 26, 2020
by
Paul McCarthy
🚵
Browse files
RF: Downloaded archive file removed before re-downloading if checksums don't
match. Error messages on assertion checks.
parent
104b1b8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
fsl/add_module/routines.py
View file @
1b88590d
...
...
@@ -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
)
...
...
fsl/add_module/ui.py
View file @
1b88590d
...
...
@@ -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
}
'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment