bored-art-40741
03/28/2021, 9:36 PMFileDigest from a file within a Digest or Snapshot? I see I can get FileContent , but I don't actually need the bytes of the file, just the fingerprintbored-art-40741
03/28/2021, 9:38 PMProcess invocation (coursier fetch ...) actually matches the digest from the lockfilehundreds-father-404
03/28/2021, 9:39 PMThe context here is that I already know the expected digestCould you use
await Get(Digest, CreateDigest([file_content]) to get the expected Digest, then compare that way?average-vr-56795
03/28/2021, 9:43 PMbored-art-40741
03/28/2021, 9:43 PMGet(FileDigest, ExtractFileDigest(digest, "some/file"))bored-art-40741
03/28/2021, 9:43 PMDownloadFile, but it looks like that's implemented in Rustbored-art-40741
03/28/2021, 9:43 PMaverage-vr-56795
03/28/2021, 9:43 PMDownloadFile which has a bogus URL, if the digest of the DownloadFile happens to be in the local cache it'll return you the Digest of the Directory containing exactly that file...average-vr-56795
03/28/2021, 9:44 PMProcess -> subset = digest of directory containing one file
Fake DownloadFile -> digest of directory containing one file (or error if it's not found)
and compare themaverage-vr-56795
03/28/2021, 9:44 PMbored-art-40741
03/28/2021, 9:44 PMDigest, I need the FileDigestbored-art-40741
03/28/2021, 9:45 PMbored-art-40741
03/28/2021, 9:45 PMfast-nail-55400
03/28/2021, 9:45 PMaverage-vr-56795
03/28/2021, 9:45 PMSnapshot existed!bored-art-40741
03/28/2021, 9:46 PMSnapshot help?fast-nail-55400
03/28/2021, 9:47 PMfast-nail-55400
03/28/2021, 9:47 PMbored-art-40741
03/28/2021, 9:47 PMSnapshotaverage-vr-56795
03/28/2021, 9:47 PMPython side?average-vr-56795
03/28/2021, 9:47 PMbored-art-40741
03/28/2021, 9:47 PMdigest of the entire snapshot, and a list of files and dirs, not their individual digestsfast-nail-55400
03/28/2021, 9:48 PMaverage-vr-56795
03/28/2021, 9:49 PMSnapshot, or an intrinsic to go from a Digest or Snapshot + path to its sha256 doesn't seem unreasonable.
(Right now we haven't because "we happen to know the sha256 of these files" is an implementation detail rather than part of the API, but it could reasonably be part of the API, even if a future change to the internals means it's less efficient to compute than it currently is, which is unlikely in the short/medium term)bored-art-40741
03/28/2021, 9:50 PMsha256 an implementation detail, but with a little design that can be maintained. It basically boils down to making FileDigest serializable, and for it to self-describe the underlying hash in a way that doesn't preclude adding or removing hash functions in the futurebored-art-40741
03/28/2021, 9:51 PMMap[FingerprintAlg, Fingerprint], where both are really just aliases for strfast-nail-55400
03/28/2021, 9:52 PMFileDigest is available in Python: https://github.com/pantsbuild/pants/blob/64a69b8e1f596308895153222c2b5e1377ccd5d3/src/python/pants/engine/fs.py#L47bored-art-40741
03/28/2021, 9:52 PMfast-nail-55400
03/28/2021, 9:53 PMSnapshot only produces the file and directory namesfast-nail-55400
03/28/2021, 9:53 PMDigestContents pulls in all of the bytesaverage-vr-56795
03/28/2021, 9:54 PMfast-nail-55400
03/28/2021, 9:54 PMDigestbored-art-40741
03/28/2021, 9:54 PMDigest -> FileContent -> FileDigest, but the FileContent.content is unnecessary for my use-case, and likely has sufficient network overhead to make a meaningful performance differencebored-art-40741
03/28/2021, 9:54 PMSnapshotfast-nail-55400
03/28/2021, 9:55 PMfast-nail-55400
03/28/2021, 9:55 PMDigestSubset to slice a Digest down to just the file you wantbored-art-40741
03/28/2021, 9:55 PMSnapshot.files (or some new field for backcompat) could be a Map[str, FileDigest]bored-art-40741
03/28/2021, 9:56 PMDigest has a single file with a known path is not a problemaverage-vr-56795
03/28/2021, 9:57 PMMap, to allow for memory optimisations, but they're morally equivalent 🙂bored-art-40741
03/28/2021, 9:59 PMGet(FileDigest, ExtractFileDigest(some_digest, "file/path"))fast-nail-55400
03/28/2021, 9:59 PMbored-art-40741
03/28/2021, 10:00 PMbored-art-40741
03/28/2021, 10:15 PMhundreds-father-404
03/28/2021, 10:17 PMbored-art-40741
03/28/2021, 10:18 PM