finally:
os.umask(old_mask)
+ # FUDGE_SECONDS is used to determine if another process
+ # has written to the same file concurrently. This is described
+ # in the Earth Dragon section of our design document:
+ # docs/proposed/magic-folder/remote-to-local-sync.rst
os.utime(replacement_path_u, (now, now - self.FUDGE_SECONDS))
if is_conflict:
print "0x00 ------------ <><> is conflict; calling _rename_conflicted_file... %r %r" % (abspath_u, replacement_path_u)
node = None
for success, result in deferredList:
if success:
- else:
- if result[1]['version'] > max_version:
- node, metadata = result
- max_version = result[1]['version']
+ if 'version' not in result[1]:
+ self._log("invalid remote metadata detected")
+ continue
++
+ if result[1]['version'] > max_version:
+ node, metadata = result
+ max_version = result[1]['version']
return node, metadata
collective_dirmap_d.addCallback(highest_version)
return collective_dirmap_d
file_node, metadata = listing_map[encoded_relpath_u]
local_version = self._get_local_latest(relpath_u)
- remote_version = metadata.get('version', None)
++
+ if 'version' not in metadata:
+ self._log("invalid remote metadata detected for %r" % (relpath_u,))
+ continue
- else:
- remote_version = metadata['version']
++
++ remote_version = metadata['version']
self._log("%r has local version %r, remote version %r" % (relpath_u, local_version, remote_version))
- if local_version is None or remote_version is None or local_version < remote_version:
+ if local_version is None or local_version < remote_version:
self._log("%r added to download queue" % (relpath_u,))
if scan_batch.has_key(relpath_u):
scan_batch[relpath_u] += [(file_node, metadata)]
path VARCHAR(1024) PRIMARY KEY, -- UTF-8 filename relative to local magic folder dir
-- note that size is before mtime and ctime here, but after in function parameters
size INTEGER, -- ST_SIZE, or NULL if the file has been deleted
- mtime NUMBER, -- ST_MTIME
- ctime NUMBER, -- ST_CTIME
+ mtime REAL, -- ST_MTIME
+ ctime REAL, -- ST_CTIME
version INTEGER,
-- last_uploaded_uri VARCHAR(256), -- URI:CHK:...
-- last_downloaded_uri VARCHAR(256), -- URI:CHK:...
- last_downloaded_timestamp TIMESTAMP
++ last_uploaded_uri VARCHAR(256), -- URI:CHK:...
++ last_downloaded_uri VARCHAR(256), -- URI:CHK:...
+ last_downloaded_timestamp REAL
);
"""