beagle r4897 - in trunk/beagle: BeagleClient Util beagled beagled/Lucene.Net/Store
- From: dbera svn gnome org
- To: svn-commits-list gnome org
- Subject: beagle r4897 - in trunk/beagle: BeagleClient Util beagled beagled/Lucene.Net/Store
- Date: Fri, 26 Dec 2008 23:55:23 +0000 (UTC)
Author: dbera
Date: Fri Dec 26 23:55:22 2008
New Revision: 4897
URL: http://svn.gnome.org/viewvc/beagle?rev=4897&view=rev
Log:
File.Delete requires write permission on the file! This is different than the POSIX behaviour and this bug was fixed in mono recently. As a result, with mono-2, beagle tmpfiles could not be deleted.
Workaround this problem by using the Mono.Unix Unlink syscall.
While there, replace the hardcoded chmod permission values by the proper enum.
Modified:
trunk/beagle/BeagleClient/Indexable.cs
trunk/beagle/Util/FileSystem.cs
trunk/beagle/beagled/Lucene.Net/Store/SimpleFSLockFactory.cs
trunk/beagle/beagled/TextCache.cs
Modified: trunk/beagle/BeagleClient/Indexable.cs
==============================================================================
--- trunk/beagle/BeagleClient/Indexable.cs (original)
+++ trunk/beagle/BeagleClient/Indexable.cs Fri Dec 26 23:55:22 2008
@@ -326,7 +326,7 @@
Logger.Log.Debug ("Cleaning up {0} ({1})", contentUri.LocalPath, Uri);
try {
- File.Delete (contentUri.LocalPath);
+ FileSystem.PosixDelete (contentUri.LocalPath);
} catch {
// It might be gone already, so catch the exception.
}
@@ -339,7 +339,7 @@
Logger.Log.Debug ("Cleaning up {0} ({1})", hotContentUri.LocalPath, Uri);
try {
- File.Delete (hotContentUri.LocalPath);
+ FileSystem.PosixDelete (hotContentUri.LocalPath);
} catch {
// Ditto
}
@@ -635,7 +635,7 @@
// Make sure the temporary file is only readable by the owner.
// FIXME: There is probably a race here. Could some malicious program
// do something to the file between creation and the chmod?
- Mono.Unix.Native.Syscall.chmod (filename, (Mono.Unix.Native.FilePermissions) 256);
+ Mono.Unix.Native.Syscall.chmod (filename, Mono.Unix.Native.FilePermissions.S_IRUSR);
BufferedStream bufferedStream = new BufferedStream (fileStream);
StreamWriter writer = new StreamWriter (bufferedStream);
@@ -671,7 +671,7 @@
// Make sure the temporary file is only readable by the owner.
// FIXME: There is probably a race here. Could some malicious program
// do something to the file between creation and the chmod?
- Mono.Unix.Native.Syscall.chmod (filename, (Mono.Unix.Native.FilePermissions) 256);
+ Mono.Unix.Native.Syscall.chmod (filename, Mono.Unix.Native.FilePermissions.S_IRUSR);
BufferedStream bufferedStream = new BufferedStream (fileStream);
Modified: trunk/beagle/Util/FileSystem.cs
==============================================================================
--- trunk/beagle/Util/FileSystem.cs (original)
+++ trunk/beagle/Util/FileSystem.cs Fri Dec 26 23:55:22 2008
@@ -148,6 +148,19 @@
return path;
}
+ // Windows (and hence .Net File.Delete) requires write
+ // permission on a file to delete it. This is different from
+ // the POSIX behaviour and works against our readonly
+ // tmp files.
+ public static void PosixDelete (string path)
+ {
+ int ret = Mono.Unix.Native.Syscall.unlink (path);
+ if (ret == -1)
+ throw new System.IO.IOException (String.Format (
+ "Delete failed for {0}: {1}",
+ path,
+ Mono.Unix.Native.Stdlib.strerror (Mono.Unix.Native.Stdlib.GetLastError ())));
+ }
}
public class NoSpaceException : Exception {
Modified: trunk/beagle/beagled/Lucene.Net/Store/SimpleFSLockFactory.cs
==============================================================================
--- trunk/beagle/beagled/Lucene.Net/Store/SimpleFSLockFactory.cs (original)
+++ trunk/beagle/beagled/Lucene.Net/Store/SimpleFSLockFactory.cs Fri Dec 26 23:55:22 2008
@@ -260,13 +260,7 @@
public override void Release()
{
- int fd = Mono.Unix.Native.Syscall.unlink (
- lockFile.FullName);
- if (fd == -1)
- throw new System.IO.IOException (
- "Could not release lock file: "
- + Mono.Unix.Native.Stdlib.strerror (Mono.Unix.Native.Stdlib.GetLastError ()
- ));
+ Beagle.Util.FileSystem.PosixDelete (lockFile.FullName);
if (System.IO.File.Exists(lockFile.FullName)) {
Beagle.Util.Logger.Log.Warn ("Release didnt delete lockfile {0}.", lockFile.FullName);
Modified: trunk/beagle/beagled/TextCache.cs
==============================================================================
--- trunk/beagle/beagled/TextCache.cs (original)
+++ trunk/beagle/beagled/TextCache.cs Fri Dec 26 23:55:22 2008
@@ -380,7 +380,10 @@
if (! world_readable) {
// Make files only readable by the owner.
- Mono.Unix.Native.Syscall.chmod (path, (Mono.Unix.Native.FilePermissions) 384);
+ Mono.Unix.Native.Syscall.chmod (
+ path,
+ Mono.Unix.Native.FilePermissions.S_IRUSR |
+ Mono.Unix.Native.FilePermissions.S_IWUSR);
}
stream = file_stream;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]