Пример #1
0
	def post_process(self, source_rorp, dest_rorp, changed, success, inc):
		"""Post process source_rorp and dest_rorp.

		The point of this is to write statistics and metadata.

		changed will be true if the files have changed.  success will
		be true if the files have been successfully updated (this is
		always false for un-changed files).

		"""
		if Globals.preserve_hardlinks and source_rorp:
			Hardlink.del_rorp(source_rorp)

		if not changed or success:
			if source_rorp: self.statfileobj.add_source_file(source_rorp)
			if dest_rorp: self.statfileobj.add_dest_file(dest_rorp)
		if success == 0: metadata_rorp = dest_rorp
		elif success == 1: metadata_rorp = source_rorp
		else: metadata_rorp = None # in case deleted because of ListError
		if success == 1 or success == 2: 
			self.statfileobj.add_changed(source_rorp, dest_rorp)

		if metadata_rorp and metadata_rorp.lstat():
			self.metawriter.write_object(metadata_rorp)
		if Globals.file_statistics:
			statistics.FileStats.update(source_rorp, dest_rorp, changed, inc)
Пример #2
0
def get_hash (repo_rorp):
	""" Try to get a sha1 digest from the repository.  If hardlinks 
	are saved in the metadata, get the sha1 from the first hardlink """
	Hardlink.add_rorp(repo_rorp)
	if Hardlink.islinked(repo_rorp):
		verify_sha1 = Hardlink.get_sha1(repo_rorp)
	elif repo_rorp.has_sha1():
		verify_sha1 = repo_rorp.get_sha1()
	else:
		verify_sha1 = None
	Hardlink.del_rorp(repo_rorp)
	return verify_sha1