Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #461.
Empty files previously returned
nullfor all checksums (sha1,md5,sha256,sha512,sha1_git) and there was no way to tell an empty file apart from a directory in scan output.This PR:
src/commoncode/hash.py:multi_checksums()now returns the real checksums of empty content for empty files (md5d41d8cd98f00b204e9800998ecf8427e, sha1da39a3ee5e6b4b0d3255bfef95601890afd80709, sha256e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855, sha512cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e, sha1_gite69de29bb2d1d6434b8b29ae775ad8c2e48c5391). Non-files still returnNone.src/scancode/api.py+src/scancode/plugin_info.py: newis_emptyfile-info flag —trueonly for real files with size 0; directories are neveris_empty.test_checksum_empty_file, addedtest_multi_checksums_empty_fileandtest_multi_checksums_empty_file_unknown_algorithmintests/commoncode/test_hash.py; updatedtest_get_file_info_include_sizeintests/scancode/test_api.py; 41 golden files updated (onlyis_emptyadditions and empty-file checksum changes).Test results (local,
PYTHONPATH=src):tests/commoncode/test_hash.py+tests/scancode/test_api.py: 38 passed.tests/licensedcode/(excludingtest_license_db.py, which cannot be collected here — pre-existingdistutilsremoval on Python 3.12): 474 passed, 0 failed.tests/packagedcode/: 25 failures, failure list identical before/after the change (all pre-existing).--infosmoke scan: empty file → real sha1 +is_empty: true; non-empty file → normal checksums,is_empty: false; directory →is_empty: false.