git » abk » commit cb34dc2

Defer metadata updates (again)

author
2005-03-02 21:45:53 UTC
committer
2005-03-02 21:45:53 UTC
parent 3e2ed1baccc75ed37b0019da3fce19dc46dc7f63

Defer metadata updates (again)

abk +17 -9

diff --git a/abk b/abk
index 4e14a38..e712ba7 100644
--- a/abk
+++ b/abk
@@ -295,6 +295,7 @@ srcidx.save()
 print "sync"
 
 # compare them
+update_files = []
 for f in srcidx.names:
 	if f not in dstidx.names or not srcidx.db[f].cmp_data(dstidx.db[f]):
 		# files missing in destination, or data changed
@@ -302,19 +303,26 @@ for f in srcidx.names:
 		print 'data\t', f, dst
 		quiet_unlink(dst)
 		srcidx.db[f].copy_file(dst)
-		srcidx.db[f].update_mdata(dst)
+		update_files.append((f, dst))
 	elif not srcidx.db[f].cmp_mdata(dstidx.db[f]):
 		# metadata changed
 		dst = os.path.join(dst_path, f)
 		print 'mdata\t', f, dst
-		try:
-			srcidx.db[f].update_mdata(dst)
-		except:
-			# it can fail if the destination doesn't have the
-			# file, ignore for now; TODO: output some kind of
-			# script so people can run it later when they get all
-			# back together
-			pass
+		update_files.append((f, dst))
+	
+# metadata gets changed later because otherwise we could leave directory times
+# wrong due to files being added to a directory after their creation; this way
+# we're sure there will be no more file creation afterwards
+print 'mdata'
+for f, dst in update_files:
+	try:
+		srcidx.db[f].update_mdata(dst)
+	except:
+		# it can fail if the destination doesn't have the
+		# file, ignore for now; TODO: output some kind of
+		# script so people can run it later when they get all
+		# back together
+		pass
 
 for f in dstidx.names:
 	if f not in srcidx.names: