hash-addressed-cli: Hash-addressed file storage

[ apache, filesystem, hash, library, program ] [ Propose Tags ]

A command-line interface for maintaining a directory wherein each file's name is a hash of its content.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0.0, 2.0.0.0, 2.1.0.0, 2.1.0.1
Change log changelog.md
Dependencies base (>=4.16 && <4.18), bytestring (>=0.11.3 && <0.12), cryptohash-sha256 (>=0.11.102 && <0.12), directory (>=1.3.6 && <1.4), filepath (>=1.4.2 && <1.5), hash-addressed (>=0.0.0 && <0.1), ini (>=0.4.2 && <0.5), optparse-applicative (>=0.16.1 && <0.17 || >=0.17.0 && <0.18), quaalude (>=0.0.0 && <0.1), resourcet (>=1.2.6 && <1.3 || >=1.3.0 && <1.4), text (>=1.2.5 && <1.3 || >=2.0.1 && <2.1), transformers (>=0.5.6 && <0.6), unordered-containers (>=0.2.17 && <0.3) [details]
License Apache-2.0
Copyright 2023 Mission Valley Software LLC
Author Chris Martin
Maintainer Chris Martin, Julie Moronuki
Category Hash, Filesystem
Home page https://github.com/typeclasses/hash-addressed-cli
Bug tracker https://github.com/typeclasses/hash-addressed-cli/issues
Source repo head: git clone git://github.com/typeclasses/hash-addressed-cli.git
Uploaded by chris_martin at 2023-01-28T00:49:11Z
Distributions
Executables hash-addressed
Downloads 157 total (11 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2023-01-28 [all 1 reports]

Readme for hash-addressed-cli-1.0.0.0

[back to package description]

The hash-addressed executable is a command-line interface for maintaining a directory wherein each file's name is a hash of its content.

Initialization

In this demonstration, we initialize a SHA-256 hash-addressed directory at /tmp/demo.

$ hash-addressed initialize --directory /tmp/demo --hash-function sha256

This created a configuration file:

$ cat /tmp/demo/.hash-addressed/config
version: 1
hash function: sha256

Writing

We can now use the hash-addressed write command to write files into this directory. In the output we see the path to which the content was written.

$ echo "Test file 1" | hash-addressed write --target-directory /tmp/demo
/tmp/demo/ad7a409054a68314812ba3ad0e523a66593ab3404c81700d6f5c3601f0da830e
$ echo "Test file 2" | hash-addressed write --target-directory /tmp/demo
/tmp/demo/20b39ca6ca85b53be73920532fd6f9cc164317646995839e2e54a6871dc13bf7

We can verify that the file was written and that indeed its name matches its SHA-256 checksum:

$ cat /tmp/demo/20b39ca6ca85b53be73920532fd6f9cc164317646995839e2e54a6871dc13bf7
Test file 2
$ sha256sum /tmp/demo/20b39ca6ca85b53be73920532fd6f9cc164317646995839e2e54a6871dc13bf7
20b39ca6ca85b53be73920532fd6f9cc164317646995839e2e54a6871dc13bf7

Verbosity

With the --verbose flag we get some additional information, including whether the content was added or already present.

$ echo "Test file 3" | hash-addressed write --target-directory /tmp/demo --verbose
The hash function is sha256
One new file was added to the store.
/tmp/demo/efdbe264574c7440b80a2c4aaf15c18787a125b6223d05300841f32f46361e7f
$ echo "Test file 3" | hash-addressed write --target-directory /tmp/demo --verbose
The hash function is sha256
The file was already present in the store; no change was made.
/tmp/demo/efdbe264574c7440b80a2c4aaf15c18787a125b6223d05300841f32f46361e7f

File copying

Instead of reading from the standard input stream, hash-addressed can also copy a file into the store using the --source-file option.

$ echo "file content" > /tmp/demo-file
$ hash-addressed write --source-file /tmp/demo-file --target-directory /tmp/demo
/tmp/demo/694b27f021c4861b3373cd5ddbc42695c056d0a4297d2d85e2dae040a84e61df
$ cat /tmp/demo/694b27f021c4861b3373cd5ddbc42695c056d0a4297d2d85e2dae040a84e61df
file content