[f-spot] Revert "Fixed bug 402849 - prune empty directories when deleting photos"



commit 4a45bbf16210106eeca20768c935528885a4e784
Author: Ruben Vermeersch <ruben savanne be>
Date:   Thu Jul 22 16:38:02 2010 +0200

    Revert "Fixed bug 402849 - prune empty directories when deleting photos"
    
    This reverts commit 1bd991667ecf7cf3c2c78db70fd6f32c42299403.
    
    Should not have been merged yet, still reviewing it.

 src/Core/Photo.cs |   50 +++-----------------------------------------------
 1 files changed, 3 insertions(+), 47 deletions(-)
---
diff --git a/src/Core/Photo.cs b/src/Core/Photo.cs
index 1ff8d83..7b240b7 100644
--- a/src/Core/Photo.cs
+++ b/src/Core/Photo.cs
@@ -271,32 +271,22 @@ namespace FSpot
 			if (version_id == OriginalVersionId && !remove_original)
 				throw new Exception ("Cannot delete original version");
 	
-			SafeUri uri = VersionUri (version_id);
+			SafeUri uri =  VersionUri (version_id);
 	
 			if (!keep_file) {
 				GLib.File file = GLib.FileFactory.NewForUri (uri);
-				if (file.Exists)
+				if (file.Exists) 
 					try {
 						file.Trash (null);
 					} catch (GLib.GException) {
 						Log.Debug ("Unable to Trash, trying to Delete");
 						file.Delete ();
-					}
+					}	
 				try {
 					XdgThumbnailSpec.RemoveThumbnail (uri);
 				} catch {
 					//ignore an error here we don't really care.
 				}
-
-				// do we really need to check if the parent is a directory?
-				// i.e. is file.Parent always a directory if the file instance is
-				// an actual file?
-				GLib.File directory = file.Parent;
-				GLib.FileType file_type = directory.QueryFileType (GLib.FileQueryInfoFlags.None, null);
-
-				if (directory.Exists && file_type == GLib.FileType.Directory)
-					DeleteEmptyDirectory (directory);
-
 			}
 			versions.Remove (version_id);
 
@@ -310,40 +300,6 @@ namespace FSpot
 			}
 		}
 
-		private void DeleteEmptyDirectory (GLib.File directory)
-		{
-			// if the directory we're dealing with is not in the
-			// F-Spot photos directory, don't delete anything,
-			// even if it is empty
-			string photo_uri = SafeUri.UriToFilename (FSpot.Global.PhotoUri.ToString ());
-			bool path_matched = directory.Path.IndexOf (photo_uri) > -1;
-
-			if (directory.Path.Equals (photo_uri) || !path_matched)
-				return;
-
-			if (DirectoryIsEmpty (directory)) {
-				try {
-					Log.DebugFormat ("Removing empty directory: {0}", directory.Path);
-					directory.Trash (null);
-				} catch (GLib.GException) {
-					Log.DebugFormat ("Unable to Trash, trying to Delete: {0}", directory.Path);
-					directory.Delete();
-				}
-				// check to see if the parent is empty
-				DeleteEmptyDirectory (directory.Parent);
-			}
-		}
-
-		private bool DirectoryIsEmpty (GLib.File directory)
-		{
-			uint count = 0;
-			GLib.FileEnumerator list = directory.EnumerateChildren ("standard::name",
-				GLib.FileQueryInfoFlags.None, null);
-			foreach (var item in list)
-				count++;
-			return count == 0;
-		}
-
 		public uint CreateVersion (string name, uint base_version_id, bool create)
 		{
 			return CreateVersion (name, null, base_version_id, create, false);



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