Rename encoded_name_u to encoded_path_u.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2015-09-30 16:15:33 +01:00
parent 937431693d
commit dc0145f19f

View File

@ -286,27 +286,27 @@ class Uploader(QueueMixin):
print "pending = %r, about to remove %r" % (self._pending, relpath_u)
self._pending.remove(relpath_u)
encoded_name_u = magicpath.path2magic(relpath_u)
encoded_path_u = magicpath.path2magic(relpath_u)
if not pathinfo.exists:
self._log("notified object %s disappeared (this is normal)" % quote_filepath(fp))
self._count('objects_disappeared')
d2 = defer.succeed(None)
if self._db.check_file_db_exists(relpath_u):
d2.addCallback(lambda ign: self._get_metadata(encoded_name_u))
d2.addCallback(lambda ign: self._get_metadata(encoded_path_u))
current_version = self._db.get_local_file_version(relpath_u) + 1
def set_deleted(metadata):
metadata['version'] = current_version
metadata['deleted'] = True
empty_uploadable = Data("", self._client.convergence)
return self._upload_dirnode.add_file(encoded_name_u, empty_uploadable, overwrite=True, metadata=metadata)
return self._upload_dirnode.add_file(encoded_path_u, empty_uploadable, overwrite=True, metadata=metadata)
d2.addCallback(set_deleted)
def add_db_entry(filenode):
filecap = filenode.get_uri()
self._db.did_upload_version(filecap, relpath_u, current_version, pathinfo)
self._count('files_uploaded')
# FIXME consider whether it's correct to retrieve the filenode again.
d2.addCallback(lambda x: self._get_filenode(encoded_name_u))
d2.addCallback(lambda x: self._get_filenode(encoded_path_u))
d2.addCallback(add_db_entry)
d2.addCallback(lambda x: Exception("file does not exist")) # FIXME wrong
@ -318,7 +318,7 @@ class Uploader(QueueMixin):
self._notifier.watch(fp, mask=self.mask, callbacks=[self._notify], recursive=True)
uploadable = Data("", self._client.convergence)
encoded_name_u += u"@_"
upload_d = self._upload_dirnode.add_file(encoded_name_u, uploadable, metadata={"version":0}, overwrite=True)
upload_d = self._upload_dirnode.add_file(encoded_path_u, uploadable, metadata={"version":0}, overwrite=True)
def _succeeded(ign):
self._log("created subdirectory %r" % (relpath_u,))
self._count('directories_created')
@ -338,7 +338,7 @@ class Uploader(QueueMixin):
return None
uploadable = FileName(unicode_from_filepath(fp), self._client.convergence)
d2 = self._upload_dirnode.add_file(encoded_name_u, uploadable, metadata={"version":version}, overwrite=True)
d2 = self._upload_dirnode.add_file(encoded_path_u, uploadable, metadata={"version":version}, overwrite=True)
def add_db_entry(filenode):
filecap = filenode.get_uri()
self._db.did_upload_version(filecap, relpath_u, version, pathinfo)
@ -362,16 +362,16 @@ class Uploader(QueueMixin):
d.addCallbacks(_succeeded, _failed)
return d
def _get_metadata(self, encoded_name_u):
def _get_metadata(self, encoded_path_u):
try:
d = self._upload_dirnode.get_metadata_for(encoded_name_u)
d = self._upload_dirnode.get_metadata_for(encoded_path_u)
except KeyError:
return Failure()
return d
def _get_filenode(self, encoded_name_u):
def _get_filenode(self, encoded_path_u):
try:
d = self._upload_dirnode.get(encoded_name_u)
d = self._upload_dirnode.get(encoded_path_u)
except KeyError:
return Failure()
return d