Merge lp:~facundo/ubuntuone-client/file-missing-rehash into lp:ubuntuone-client

Proposed by Facundo Batista
Status: Merged
Approved by: Guillermo Gonzalez
Approved revision: 263
Merged at revision: not available
Proposed branch: lp:~facundo/ubuntuone-client/file-missing-rehash
Merge into: lp:ubuntuone-client
Diff against target: 41 lines
1 file modified
ubuntuone/syncdaemon/sync.py (+12/-12)
To merge this branch: bzr merge lp:~facundo/ubuntuone-client/file-missing-rehash
Reviewer Review Type Date Requested Status
Guillermo Gonzalez Approve
Lucio Torre (community) Approve
Review via email: mp+13666@code.launchpad.net

Commit message

Now we send to re hash a node if we receive the data but the path in disk is gone

To post a comment you must log in.
Revision history for this message
Facundo Batista (facundo) wrote :

Now we send to re hash a node if we receive the data but the path in disk
is gone.

Changing the received event from HQ_HASH_NEW to HQ_HASH_ERROR will trigger
the re hash the exact same way as if the file disappearance was seen by HQ.

Revision history for this message
Lucio Torre (lucio.torre) wrote :

+1

review: Approve
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/syncdaemon/sync.py'
2--- ubuntuone/syncdaemon/sync.py 2009-09-28 17:34:38 +0000
3+++ ubuntuone/syncdaemon/sync.py 2009-10-20 20:00:31 +0000
4@@ -317,16 +317,7 @@
5
6 def validate_actual_data(self, path, oldstat):
7 """Validates that the received info is not obsolete."""
8- try:
9- newstat = os.stat(path)
10- except OSError:
11- # the file went away between the moment HQ finished and now, we
12- # discard it (if the file would have went away moments before,
13- # this info would have been discarded by HQ itself)
14- m = "Received hash of path, but it's no longer there: %r"
15- self.log.debug(m, path)
16- return False
17-
18+ newstat = os.stat(path)
19 if newstat.st_ino != oldstat.st_ino or \
20 newstat.st_size != oldstat.st_size or \
21 newstat.st_mtime != oldstat.st_mtime or \
22@@ -1027,8 +1018,17 @@
23 key = FSKey(self.m.fs, path=path)
24 log = FileLogger(self.logger, key)
25 ssmr = SyncStateMachineRunner(self.fsm, self.m, key, log)
26- if ssmr.validate_actual_data(path, stat):
27- ssmr.signal_event_with_hash("HQ_HASH_NEW", hash, crc32, size, stat)
28+ try:
29+ data_ok = ssmr.validate_actual_data(path, stat)
30+ except OSError, e:
31+ # the file went away between the moment HQ finished and now, we
32+ # discard the info, but needs to send to rehash.
33+ log.debug("Changing HQ_HASH_NEW to ERROR in %r: %s", path, e)
34+ ssmr.on_event('HQ_HASH_ERROR', {})
35+ else:
36+ if data_ok:
37+ ssmr.signal_event_with_hash("HQ_HASH_NEW", hash,
38+ crc32, size, stat)
39
40 def handle_AQ_UPLOAD_FINISHED(self, share_id, node_id, hash):
41 """on AQ_UPLOAD_FINISHED"""

Subscribers

People subscribed via source and target branches