changeset 1677:c5c7e19fbb23

warn if another operation is performed on a file with unsaved metadata
author nadvornik
date Sun, 28 Jun 2009 09:08:25 +0000
parents d27275bc008a
children 1e3bbaa772b9
files src/filedata.c src/typedefs.h
diffstat 2 files changed, 25 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/filedata.c	Sun Jun 28 08:49:28 2009 +0000
+++ b/src/filedata.c	Sun Jun 28 09:08:25 2009 +0000
@@ -1863,6 +1863,16 @@
 	dir = remove_level_from_path(fd->path);
 	
 	if (fd->change->type != FILEDATA_CHANGE_DELETE &&
+	    fd->change->type != FILEDATA_CHANGE_MOVE && /* the unsaved metadata should survive move and rename operations */
+	    fd->change->type != FILEDATA_CHANGE_RENAME &&
+	    fd->change->type != FILEDATA_CHANGE_WRITE_METADATA &&
+	    fd->modified_xmp)
+		{
+		ret |= CHANGE_WARN_UNSAVED_META;
+		DEBUG_1("Change checked: unsaved metadata: %s", fd->path);
+		}
+	
+	if (fd->change->type != FILEDATA_CHANGE_DELETE &&
 	    fd->change->type != FILEDATA_CHANGE_WRITE_METADATA &&
 	    !access_file(fd->path, R_OK))
 		{
@@ -2137,6 +2147,12 @@
 		g_string_append(result, _("source and destination have different extension"));
 		}
 
+	if (error & CHANGE_WARN_UNSAVED_META)
+		{
+		if (result->len > 0) g_string_append(result, ", ");
+		g_string_append(result, _("there are unsaved metadata changes for the file"));
+		}
+
 	return g_string_free(result, FALSE);
 }
 
--- a/src/typedefs.h	Sun Jun 28 08:49:28 2009 +0000
+++ b/src/typedefs.h	Sun Jun 28 09:08:25 2009 +0000
@@ -157,14 +157,15 @@
 	CHANGE_WARN_NO_WRITE_PERM      = 1 << 1,
 	CHANGE_WARN_SAME               = 1 << 2,
 	CHANGE_WARN_CHANGED_EXT        = 1 << 3,
-	CHANGE_ERROR_MASK              = (~0) << 4, /* the values below are fatal errors */
-	CHANGE_NO_READ_PERM            = 1 << 4,
-	CHANGE_NO_WRITE_PERM_DIR       = 1 << 5,
-	CHANGE_NO_DEST_DIR             = 1 << 6,
-	CHANGE_NO_WRITE_PERM_DEST_DIR  = 1 << 7,
-	CHANGE_NO_WRITE_PERM_DEST      = 1 << 8,
-	CHANGE_DEST_EXISTS             = 1 << 9,
-	CHANGE_NO_SRC                  = 1 << 10,
+	CHANGE_WARN_UNSAVED_META       = 1 << 4,
+	CHANGE_ERROR_MASK              = (~0) << 8, /* the values below are fatal errors */
+	CHANGE_NO_READ_PERM            = 1 << 8,
+	CHANGE_NO_WRITE_PERM_DIR       = 1 << 9,
+	CHANGE_NO_DEST_DIR             = 1 << 10,
+	CHANGE_NO_WRITE_PERM_DEST_DIR  = 1 << 11,
+	CHANGE_NO_WRITE_PERM_DEST      = 1 << 12,
+	CHANGE_DEST_EXISTS             = 1 << 13,
+	CHANGE_NO_SRC                  = 1 << 14,
 	CHANGE_GENERIC_ERROR           = 1 << 16
 } ChangeError;