[f-spot] Do not crash when rotating an image with a non-file URI



commit 7406a0dfc4c4f5f3eb6c4f53bc25b506f144ff03
Author: Nuno Ferreira <email do nuno gmail com>
Date:   Thu Oct 21 12:53:09 2010 +0200

    Do not crash when rotating an image with a non-file URI
    
    https://bugzilla.gnome.org/show_bug.cgi?id=630863

 src/Clients/MainApp/FSpot/RotateCommand.cs |   38 +++++++++++++--------------
 1 files changed, 18 insertions(+), 20 deletions(-)
---
diff --git a/src/Clients/MainApp/FSpot/RotateCommand.cs b/src/Clients/MainApp/FSpot/RotateCommand.cs
index 0db84dd..af83645 100644
--- a/src/Clients/MainApp/FSpot/RotateCommand.cs
+++ b/src/Clients/MainApp/FSpot/RotateCommand.cs
@@ -101,31 +101,29 @@ namespace FSpot {
                 Log.DebugException (e);
                 throw new RotateException (Catalog.GetString ("Unable to rotate this type of photo"), original_path);
             }
-		}
-
-		private void Rotate (string original_path, RotateDirection dir)
-		{
-			RotateOrientation (original_path, dir);
-		}
-
-		public bool Step () {
-			string original_path;
+        }
 
-			if (done)
-				return false;
+        private void Rotate (string original_path, RotateDirection dir)
+        {
+            RotateOrientation (original_path, dir);
+        }
 
-			original_path = item.DefaultVersion.Uri.LocalPath;
-			done = true;
+        public bool Step ()
+        {
+            if (done)
+                return false;
 
-			if ((File.GetAttributes(original_path) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) {
-				throw new RotateException (Catalog.GetString ("Unable to rotate readonly file"), original_path, true);
-			}
+            GLib.FileInfo info = GLib.FileFactory.NewForUri (item.DefaultVersion.Uri).QueryInfo ("access::can-write", GLib.FileQueryInfoFlags.None, null);
+            if (!info.GetAttributeBoolean("access::can-write")) {
+                throw new RotateException (Catalog.GetString ("Unable to rotate readonly file"), item.DefaultVersion.Uri, true);
+            }
 
-			Rotate (original_path, direction);
+            Rotate (item.DefaultVersion.Uri, direction);
 
-			return !done;
-		}
-	}
+            done = true;
+            return !done;
+        }
+    }
 
 	public class RotateMultiple {
 		RotateDirection direction;



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