-
Notifications
You must be signed in to change notification settings - Fork 7
add check for snapshot integrity #74
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
Open
FedeDR
wants to merge
7
commits into
corso-python-prato:master
Choose a base branch
from
FedeDR:fix_shap_update
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8e30406
add redundant check for snapshot integrity
FedeDR 4c5a60f
fix refuse
FedeDR 84c81ec
inhibit _remove_snapshot_orphan function in unit test
FedeDR 38763fe
remove redundant snapshot check
FedeDR 099b033
add internal conflick error flag for sincronize dispatcher delete pro…
FedeDR 84315ee
remove refuse in test
FedeDR 2cc8be1
add comment
FedeDR 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -806,6 +806,9 @@ def __init__(self, snapshot_file_path): | |
| self.last_status = self._load_status() | ||
| self.local_full_snapshot = self.instant_snapshot() | ||
|
|
||
| #flag enabled only when there is a conflict in sinchronize. enable inhibit of some check | ||
| self.conflicted_sync = False | ||
|
|
||
| def local_check(self): | ||
| """ check id daemon is synchronized with local directory """ | ||
| local_global_snapshot = self.global_md5() | ||
|
|
@@ -870,8 +873,11 @@ def save_snapshot(self, timestamp): | |
|
|
||
| def update_snapshot_upload(self, body): | ||
| """ update of local full snapshot by upload request""" | ||
| self.local_full_snapshot[self.file_snapMd5( | ||
| body['src_path'])] = [get_relpath(body["src_path"])] | ||
| md5_file = self.file_snapMd5(body['src_path']) | ||
| if md5_file in self.local_full_snapshot: | ||
| self.local_full_snapshot[md5_file].append(get_relpath(body["src_path"])) | ||
| else: | ||
| self.local_full_snapshot[md5_file] = [get_relpath(body["src_path"])] | ||
|
|
||
| def update_snapshot_update(self, body): | ||
| """ update of local full snapshot by update request""" | ||
|
|
@@ -889,24 +895,36 @@ def update_snapshot_update(self, body): | |
|
|
||
| def update_snapshot_copy(self, body): | ||
| """ update of local full snapshot by copy request""" | ||
| self.local_full_snapshot[self.file_snapMd5( | ||
| body['src_path'])].append(get_relpath(body["dst_path"])) | ||
| md5_file = self.file_snapMd5(body['src_path']) | ||
| paths_of_file = self.local_full_snapshot[md5_file] | ||
| paths_of_file.append(get_relpath(body["dst_path"])) | ||
|
|
||
| def update_snapshot_move(self, body): | ||
| """ update of local full snapshot by move request""" | ||
| paths_of_file = self.local_full_snapshot[self.file_snapMd5( | ||
| get_abspath(body["dst_path"]))] | ||
| paths_of_file.remove(get_relpath(body["src_path"])) | ||
| md5_file = self.file_snapMd5(get_abspath(body["dst_path"])) | ||
| paths_of_file = self.local_full_snapshot[md5_file] | ||
| try: | ||
| paths_of_file.remove(get_relpath(body["src_path"])) | ||
| except ValueError: | ||
| #if it is in internal conflict check sinchronize the error is inhibit | ||
| if not self.conflicted_sync: | ||
|
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. ... e qui :) |
||
| raise | ||
| paths_of_file.append(get_relpath(body["dst_path"])) | ||
|
|
||
| def update_snapshot_delete(self, body): | ||
| """ update of local full snapshot by delete request""" | ||
| md5_file = self.find_file_md5(self.local_full_snapshot, get_relpath(body['src_path']), False) | ||
| logger.debug("find md5: {}".format(md5_file)) | ||
| if len(self.local_full_snapshot[md5_file]) == 1: | ||
| del self.local_full_snapshot[md5_file] | ||
| else: | ||
| self.local_full_snapshot[md5_file].remove(get_relpath(body['src_path'])) | ||
| if md5_file in self.local_full_snapshot: | ||
| try: | ||
| self.local_full_snapshot[md5_file].remove( | ||
| get_relpath(body['src_path'])) | ||
| except ValueError: | ||
| #if it is in internal conflict check sinchronize the error is inhibit | ||
| if not self.conflicted_sync: | ||
| raise | ||
| if len(self.local_full_snapshot[md5_file]) == 0: | ||
| del self.local_full_snapshot[md5_file] | ||
| logger.debug("path deleted: " + get_relpath(body['src_path'])) | ||
|
|
||
| def save_timestamp(self, timestamp): | ||
|
|
@@ -959,6 +977,7 @@ def synchronize_dispatcher(self, server_timestamp, server_snapshot): | |
| command_list = [] | ||
| #NO internal conflict | ||
| if self.local_check(): # 1) | ||
| self.conflicted_sync = False | ||
| if not self.is_syncro(server_timestamp): # 1) b. | ||
| for new_server_path in new_server_paths: # 1) b 1 | ||
| server_md5 = self.find_file_md5(server_snapshot, new_server_path) | ||
|
|
@@ -987,6 +1006,7 @@ def synchronize_dispatcher(self, server_timestamp, server_snapshot): | |
|
|
||
| #internal conflicts | ||
| else: # 2) | ||
| self.conflicted_sync = True | ||
| if self.is_syncro(server_timestamp): # 2) a | ||
| logger.debug("****\tpush all\t****") | ||
| for new_server_path in new_server_paths: # 2) a 1 | ||
|
|
@@ -1036,6 +1056,7 @@ def synchronize_dispatcher(self, server_timestamp, server_snapshot): | |
| for new_client_path in new_client_paths: # 2) b 3 | ||
| logger.debug("remove remote\t{}".format(new_client_path)) | ||
| command_list.append({'remote_delete': [new_client_path]}) | ||
| self.conflicted_sync = False | ||
|
|
||
| return command_list | ||
|
|
||
|
|
||
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.
Aggiungi un commento qui....