Skip to content

dfget support digest for directory #1561

@pirDOL

Description

@pirDOL

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:

  1. Using relative path to store digest file makes digest and download file same source.
  2. Using a file which contains multiple digests of each file in directory can avoid too long command line args.
  3. Using url to locate each file and as digest file key makes it easier to get digest by url
  4. 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

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions