beagle r4899 - trunk/beagle/Filters



Author: dbera
Date: Sat Dec 27 17:15:07 2008
New Revision: 4899
URL: http://svn.gnome.org/viewvc/beagle?rev=4899&view=rev

Log:
Do some more tmp file permission fixing - this time in FilterArchive.


Modified:
   trunk/beagle/Filters/FilterArchive.cs

Modified: trunk/beagle/Filters/FilterArchive.cs
==============================================================================
--- trunk/beagle/Filters/FilterArchive.cs	(original)
+++ trunk/beagle/Filters/FilterArchive.cs	Sat Dec 27 17:15:07 2008
@@ -227,12 +227,17 @@
 				return null;
 
 			string filename = FileSystem.GetTempFileName (extension);
-			FileStream file_stream = File.OpenWrite (filename);
+			FileStream file_stream = new FileStream (filename, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite); // FileShare.ReadWrite needed for setting the mtime
+
+			// When we dump the contents of an indexable into a file, we
+			// expect to use it again soon.
+			FileAdvise.PreLoad (file_stream);
 
 			//Log.Debug ("Storing archive contents in {0}", filename);
-			
-			Mono.Unix.Native.Syscall.chmod (filename, (Mono.Unix.Native.FilePermissions) 384); // 384 is 0600
-			
+
+			File.SetLastWriteTimeUtc (filename, mtime); // change this before making read-only
+			Mono.Unix.Native.Syscall.chmod (filename, Mono.Unix.Native.FilePermissions.S_IRUSR);
+
 			BufferedStream buffered_stream = new BufferedStream (file_stream);
 
 			byte [] buffer = new byte [8192];
@@ -286,14 +291,10 @@
 			buffered_stream.Close ();
 
 			if (skip_file) {
-				File.Delete (filename);
+				FileSystem.PosixDelete (filename);
 				return null;
 			}
 
-			File.SetLastWriteTimeUtc (filename, mtime);
-
-			Mono.Unix.Native.Syscall.chmod (filename, (Mono.Unix.Native.FilePermissions) 256); // 256 is 0400
-
 			return filename;
 		}
 



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