git » abk » commit 38a7f39

Unify the metadata updates.

author
2005-03-02 05:56:47 UTC
committer
2005-03-02 05:56:47 UTC
parent 654b01acd5f37c7f005fe9c52fe50a551ed41af1

Unify the metadata updates.
This patch unifies the function where metadata takes place, so we can then
split between data and metadata updates.

abk +13 -9

diff --git a/abk b/abk
index 58a88fa..f7dcd2e 100644
--- a/abk
+++ b/abk
@@ -110,18 +110,11 @@ class file_info:
 		sfile.close()
 		dfile.close()
 
-		os.chmod(dst, self.mode & 07777)	# FIXME: is this linux-only?
-		os.chown(dst, self.uid, self.gid)
-		os.utime(dst, (self.atime, self.mtime))
-
 
 	def copy_file_link(self, dst):
 		"Copy a symbolic link."
 		linkto = os.readlink(self.name)
 		os.symlink(linkto, dst)
-		os.lchown(dst, self.uid, self.gid)
-		# note that we don't chmod, because it will change the
-		# destination owner instead of the link's.
 
 
 	def copy_file_dev(self, dst):
@@ -130,8 +123,15 @@ class file_info:
 		minor = os.minor(self.rdev)
 		dev = os.makedev(major, minor)
 		os.mknod(dst, self.mode, dev)
-		os.chmod(dst, self.mode & 07777)
-		os.chown(dst, self.uid, self.gid)
+
+
+	def update_mdata(self, dst):
+		"Updates a file's metadata."
+		os.lchown(dst, self.uid, self.gid)
+		if self.type != 'l':
+			# these don't really like symlinks
+			os.utime(dst, (self.atime, self.mtime))
+			os.chmod(dst, self.mode & 07777)
 
 
 	def copy_file(self, dst):
@@ -156,6 +156,10 @@ class file_info:
 		else:
 			raise 'Unk type: 0x%x %d' % (self.mode, self.name)
 
+		# no need to update metadata if we're going to do it
+		# afterwards
+		#self.update_mdata(dst)
+
 
 	def hash_file(self):
 		"Returns the sha1sum of a file."