-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
Feature request:
support digest for directory to verify the integrity of the downloaded file
Use case:
now:
--digest <algorithm>:<digest>proposal:
--digest <algorithm>:<digest> # for backward compatibility
--digest file://<path> # new format, <path> is relative to download URL
/path/to/digest/file is in json
{
"<URL1>": {"algorithm": "str", "digest": "str"},
"<URL2>": {"algorithm": "str", "digest": "str"},
...
}key design point:
- Using relative path to store digest file makes digest and download file same source.
- Using a file which contains multiple digests of each file in directory can avoid too long command line args.
- Using url to locate each file and as digest file key makes it easier to get digest by url
- The url of the digest itself can be also stored in the digest file, which is used to check the integrity of digest itself.
dfget pseudo code
# 1 download and check digest
if --digest file://; then
digest_file_content = download(digest_url)
fi
# 2 parse digest
url2digest = json.unmarshal(digest_file_content)
# 3 check digest integrity
if url2digest[digest_file_path] != digest(digest_file_content)
exit(1)
# 4 pass url2digest to DownloadRequest when download dir
entry_args.url = entry_url
entry_args.digest = url2digest[entry_url]
# 4 download directory
...
UI Example:
NA