mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-20 11:38:52 +00:00
Extract get_metadata and get_filenode to methods of Uploader.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
8eb81b84f2
commit
144f4ff5ff
@ -291,25 +291,13 @@ class Uploader(QueueMixin):
|
|||||||
self._pending.remove(path_u) # FIXME make _upload_pending hold relative paths
|
self._pending.remove(path_u) # FIXME make _upload_pending hold relative paths
|
||||||
relpath_u = os.path.relpath(path_u, self._local_path_u)
|
relpath_u = os.path.relpath(path_u, self._local_path_u)
|
||||||
encoded_name_u = magicpath.path2magic(relpath_u)
|
encoded_name_u = magicpath.path2magic(relpath_u)
|
||||||
def get_metadata(result):
|
|
||||||
try:
|
|
||||||
metadata_d = self._upload_dirnode.get_metadata_for(encoded_name_u)
|
|
||||||
except KeyError:
|
|
||||||
return Failure()
|
|
||||||
return metadata_d
|
|
||||||
def get_filenode(path_u):
|
|
||||||
try:
|
|
||||||
node_d = self._upload_dirnode.get(path_u)
|
|
||||||
except KeyError:
|
|
||||||
return Failure()
|
|
||||||
return node_d
|
|
||||||
if not os.path.exists(path_u):
|
if not os.path.exists(path_u):
|
||||||
self._log("drop-upload: notified object %r disappeared "
|
self._log("drop-upload: notified object %r disappeared "
|
||||||
"(this is normal for temporary objects)" % (path_u,))
|
"(this is normal for temporary objects)" % (path_u,))
|
||||||
self._count('objects_disappeared')
|
self._count('objects_disappeared')
|
||||||
d2 = defer.succeed(None)
|
d2 = defer.succeed(None)
|
||||||
if self._db.check_file_db_exists(relpath_u):
|
if self._db.check_file_db_exists(relpath_u):
|
||||||
d2.addCallback(get_metadata)
|
d2.addCallback(lambda ign: self._get_metadata(encoded_name_u))
|
||||||
current_version = self._db.get_local_file_version(relpath_u) + 1
|
current_version = self._db.get_local_file_version(relpath_u) + 1
|
||||||
def set_deleted(metadata):
|
def set_deleted(metadata):
|
||||||
print "SET_DELETED new version %s----------------------------------------------" % (current_version,)
|
print "SET_DELETED new version %s----------------------------------------------" % (current_version,)
|
||||||
@ -328,7 +316,7 @@ class Uploader(QueueMixin):
|
|||||||
self._db.did_upload_file(filecap, relpath_u, current_version, int(mtime), int(ctime), size)
|
self._db.did_upload_file(filecap, relpath_u, current_version, int(mtime), int(ctime), size)
|
||||||
print "after change magic-folder db %s %s %s %s %s %s-----------------------" % (filecap, relpath_u, current_version, mtime, ctime, size)
|
print "after change magic-folder db %s %s %s %s %s %s-----------------------" % (filecap, relpath_u, current_version, mtime, ctime, size)
|
||||||
self._count('files_uploaded')
|
self._count('files_uploaded')
|
||||||
d2.addCallback(lambda x: get_filenode(encoded_name_u))
|
d2.addCallback(lambda x: self._get_filenode(encoded_name_u))
|
||||||
d2.addCallback(add_db_entry)
|
d2.addCallback(add_db_entry)
|
||||||
|
|
||||||
d2.addCallback(lambda x: Exception("file does not exist"))
|
d2.addCallback(lambda x: Exception("file does not exist"))
|
||||||
@ -388,6 +376,20 @@ class Uploader(QueueMixin):
|
|||||||
d.addBoth(self._do_callback)
|
d.addBoth(self._do_callback)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def _get_metadata(self, encoded_name_u):
|
||||||
|
try:
|
||||||
|
d = self._upload_dirnode.get_metadata_for(encoded_name_u)
|
||||||
|
except KeyError:
|
||||||
|
return Failure()
|
||||||
|
return d
|
||||||
|
|
||||||
|
def _get_filenode(self, encoded_name_u):
|
||||||
|
try:
|
||||||
|
d = self._upload_dirnode.get(encoded_name_u)
|
||||||
|
except KeyError:
|
||||||
|
return Failure()
|
||||||
|
return d
|
||||||
|
|
||||||
|
|
||||||
class Downloader(QueueMixin):
|
class Downloader(QueueMixin):
|
||||||
def __init__(self, client, local_path_u, db, collective_dircap):
|
def __init__(self, client, local_path_u, db, collective_dircap):
|
||||||
|
Loading…
Reference in New Issue
Block a user