blam r625 - trunk/src



Author: cmartin
Date: Sat Sep  6 10:32:48 2008
New Revision: 625
URL: http://svn.gnome.org/viewvc/blam?rev=625&view=rev

Log:
Make channel list save atomic.

Use the Replace method instead of Remove + Move in order to make
saving collection.xml an atomic operation.
This fixes the race condition in GNOME bug #346553.

Modified:
   trunk/src/ChannelCollection.cs

Modified: trunk/src/ChannelCollection.cs
==============================================================================
--- trunk/src/ChannelCollection.cs	(original)
+++ trunk/src/ChannelCollection.cs	Sat Sep  6 10:32:48 2008
@@ -130,13 +130,9 @@
 
 		// Move the file to the real one
 		try {
-		    if (File.Exists (this.FileName)) {
-			File.Delete (this.FileName);
-		    }
-
-		    File.Move (tmpFile, this.FileName);
+		    File.Replace (tmpFile, this.FileName, this.FileName + ".bk");
 		} catch (Exception e) {
-		    Console.Error.WriteLine ("Move failed: " + e.Message);
+		    Console.Error.WriteLine ("File replace error: " + e.Message);
 		    return;
 		}
 		



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]