Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should calculating a checksum on a file be cached? #235

Open
malmond77 opened this issue Mar 15, 2021 · 3 comments
Open

Should calculating a checksum on a file be cached? #235

malmond77 opened this issue Mar 15, 2021 · 3 comments

Comments

@malmond77
Copy link
Contributor

See https://github.com/rpm-software-management/librepo/pull/234/files/2743583e444d745526e9bb8fad249ce6ea08e0f9#r594141462 for context

@m-blaha suggests that all calculated checksums should be eligible for caching, if caching == TRUE when calling lr_checksum_fd_compare. I tend to agree, but the cache key does not indicate which hash algorithm was used, so we need to resolve that first. If we don't, an md5 checksum would be cached, which would never match a sha256 for example.

@m-blaha
Copy link
Member

m-blaha commented Mar 16, 2021

The keys (xattrs names) has changed recently (see 7a7cd44)
Originally the cache key was something like user.Zif.MdChecksum[123456] where 123455 was mtime of the file. This caused problems precisely because the hash algorithm was not stored. Now we use two keys instead - user.Librepo.checksum.mtime for the timestamp and a set of user.Librepo.checksum.HASH_TYPE for actual checksums. HASH_TYPE is most often sha256, but could vary according the hash used in particular repositories.

@malmond77
Copy link
Contributor Author

@m-blaha : awesome - I didn't pick up on the keys being fixed in this way before. Now that this is resolved, what is your opinion? Is this safe to implement?

@m-blaha
Copy link
Member

m-blaha commented Mar 22, 2021

I think it is. Once the right checksum of the file is calculated, it can be saved in xattr for future usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants