-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[WIP] Support for alternative hashes (#1676) #2022
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
Closed
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
55349af
config: Alterative hashings for data (#1676)
vyloy 6453c16
config: use hash section for hashing configuration
vyloy 7ebedc4
utils: rename file_md5 to file_checksum, dict_md5 to dict_checksum
vyloy a367dc3
stage: rename _compute_md5 to _compute_checksum
vyloy e8d790c
remote: fix error
vyloy 52f67de
remote: improve some details about PARAM_CHECKSUM
vyloy 31616f3
config: separate hash library and improve some details
vyloy e941d7c
hash: add a test about changed file
vyloy b2ecd91
remote: improvements after more tests
vyloy 3f0b14b
rename variable to fix python2.7 object does not support item assignm…
vyloy b2a25a0
rename mod hash to checksum
vyloy de52cf0
refactor the code to deal with checksum type
vyloy 90d65a2
rename legacy function about md5 to checksum
vyloy f62d053
collect schemas
vyloy 060f632
increase state version
vyloy 62c6339
fix error after rebase
vyloy 44059a5
refactor remote.changed
vyloy f0dbadf
rename get_prefer_checksum_type to checksum_type
vyloy 6728cea
remote: initially add checksum types config ability for other remotes
vyloy befb5ee
move dict filter to utils collections
shcheklein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,9 +141,20 @@ def cache_path(self): | |
| def sep(self): | ||
| return "/" | ||
|
|
||
| @property | ||
| def checksum_type(self): | ||
| for t in self.remote.checksum_types(): | ||
| if t in self.info: | ||
| return t | ||
| return None | ||
|
|
||
| @property | ||
| def checksum(self): | ||
| return self.info.get(self.remote.PARAM_CHECKSUM) | ||
| for t in self.remote.checksum_types(): | ||
| info = self.info.get(t) | ||
| if info: | ||
| return info | ||
| return None | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be: return next((self.info[t] for t in self.remote.checksum_types() if t in self.info), None)
# or
return next(filter(bool, map(self.info.get, self.remote.checksum_types())), None) :)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or return self.info[self.checksum] |
||
|
|
||
| @property | ||
| def is_dir_checksum(self): | ||
|
|
@@ -154,18 +165,13 @@ def exists(self): | |
| return self.remote.exists(self.path_info) | ||
|
|
||
| def changed_checksum(self): | ||
| return ( | ||
| self.checksum | ||
| != self.remote.save_info(self.path_info)[ | ||
| self.remote.PARAM_CHECKSUM | ||
| ] | ||
| ) | ||
| return self.cache.changed_checksum(self.path_info, self.info) | ||
|
|
||
| def changed_cache(self): | ||
| if not self.use_cache or not self.checksum: | ||
| return True | ||
|
|
||
| return self.cache.changed_cache(self.checksum) | ||
| return self.cache.changed_cache(self.checksum, self.checksum_type) | ||
|
|
||
| def status(self): | ||
| if self.checksum and self.use_cache and self.changed_cache(): | ||
|
|
||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simply:
?