Giter VIP home page Giter VIP logo

filehash's People

Contributors

leonidessaguisagjr avatar mmore500 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

filehash's Issues

Md5sum files unsupported

The Md5sum files (*.md5) I am working with are failing verification when I use FileHash.verify_checksums(), because they are separated with two spaces:

% cat something-or-other-arch-v0.0.1.tar.gz.md5
595f44fec1e92a71d3e9e77456ba80d1  something-or-other-arch-v0.0.1.tar.gz

This is the error I get:

FileNotFoundError: [Errno 2] No such file or directory: ' something-or-other-arch-v0.0.1.tar.gz'

The output of the md5sum utility is described here:

https://en.wikipedia.org/wiki/Md5sum

Bug with SHA256 checksums

On MacOS, "sha256sum" generates a file with two spaces between the hash and the filename. This causes filehash to fail verification while sha256sum works fine. This is due to the fact that text files are marked with a " " / space, and binary files with "*":
https://linux.die.net/man/1/sha256sum

To replicate, run the following commands:

cd testdata/
sha256sum *.zip >mac_test.txt
sha256sum --check mac_test.txt
chkfilehash -c mac_test.txt

Output from sha256sum:

lorem_ipsum.zip: OK

Output from fileshash:

Traceback (most recent call last):
  File "/usr/local/bin/chkfilehash", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/filehash/filehash_cli.py", line 100, in main
    process_checksum_file(args.checksums, hasher)
  File "/usr/local/lib/python3.9/site-packages/filehash/filehash_cli.py", line 82, in process_checksum_file
    results = hasher.verify_checksums(checksum_filename)
  File "/usr/local/lib/python3.9/site-packages/filehash/filehash.py", line 268, in verify_checksums
    actual_hash = self.hash_file(filename)
  File "/usr/local/lib/python3.9/site-packages/filehash/filehash.py", line 176, in hash_file
    with open(filename, mode="rb", buffering=0) as fp:
FileNotFoundError: [Errno 2] No such file or directory: ' lorem_ipsum.zip'
```

Paths within checksum should be evaluated relative to the checksum file directory, not the current working directory

Changing directories before I verify is not a big deal when using a shell and verifying manually. But if I'm reaching for Python, chances are I'm either verifying a large number of multiple packages, or I'm writing a script to automate.

Either way, it seems like something a library should be handling for me.

Currently, this is required (I'm sure others could do it with less mess):

checksum_path = './relpath/package.md5'
orig = os.currdir
os.chdir(os.path.dirname(checksum_path))
filehash.verify_checksums(os.path.basename(checksum_path))
os.chdir(orig)

If checksums were always evaluated from the directory they're in, I could do this:

checksum_path = './relpath/package.md5'
filehash.verify_checksums(checksum_path)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.