[f-spot] Make sure metadata write on rotate also works for broken files.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot] Make sure metadata write on rotate also works for broken files.
- Date: Mon, 13 Sep 2010 08:38:49 +0000 (UTC)
commit 485c1ff690195d7f1ad0896eb62d9d9dbf72b0b4
Author: Ruben Vermeersch <ruben savanne be>
Date: Mon Sep 13 10:23:11 2010 +0200
Make sure metadata write on rotate also works for broken files.
https://bugzilla.gnome.org/show_bug.cgi?id=624775
src/Clients/MainApp/FSpot.Jobs/SyncMetadataJob.cs | 12 +----------
src/Clients/MainApp/FSpot/RotateCommand.cs | 8 +++++-
src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs | 23 ++++++++++++++++++++-
3 files changed, 29 insertions(+), 14 deletions(-)
---
diff --git a/src/Clients/MainApp/FSpot.Jobs/SyncMetadataJob.cs b/src/Clients/MainApp/FSpot.Jobs/SyncMetadataJob.cs
index 6b1c9c1..d580a82 100644
--- a/src/Clients/MainApp/FSpot.Jobs/SyncMetadataJob.cs
+++ b/src/Clients/MainApp/FSpot.Jobs/SyncMetadataJob.cs
@@ -70,17 +70,7 @@ namespace FSpot.Jobs {
tag.Software = Defines.PACKAGE + " version " + Defines.VERSION;
var always_sidecar = Preferences.Get<bool> (Preferences.METADATA_ALWAYS_USE_SIDECAR);
- if (always_sidecar || !metadata.Writeable || metadata.PossiblyCorrupt) {
- if (!always_sidecar && metadata.PossiblyCorrupt) {
- Log.WarningFormat (Catalog.GetString ("Metadata of file {0} may be corrupt, refusing to write to it, falling back to XMP sidecar."), photo.DefaultVersion.Uri);
- }
-
- var sidecar_res = new GIOTagLibFileAbstraction () { Uri = photo.DefaultVersion.Uri.ReplaceExtension (".xmp") };
-
- metadata.SaveXmpSidecar (sidecar_res);
- } else {
- metadata.Save ();
- }
+ metadata.SaveSafely (photo.DefaultVersion.Uri, always_sidecar);
}
}
}
diff --git a/src/Clients/MainApp/FSpot/RotateCommand.cs b/src/Clients/MainApp/FSpot/RotateCommand.cs
index edad894..603ab51 100644
--- a/src/Clients/MainApp/FSpot/RotateCommand.cs
+++ b/src/Clients/MainApp/FSpot/RotateCommand.cs
@@ -61,14 +61,18 @@ namespace FSpot {
private static void RotateOrientation (string original_path, RotateDirection direction)
{
try {
- using (var metadata = Metadata.Parse (new SafeUri (original_path))) {
+ var uri = new SafeUri (original_path);
+ using (var metadata = Metadata.Parse (uri)) {
+ metadata.EnsureAvailableTags ();
var tag = metadata.ImageTag;
var orientation = direction == RotateDirection.Clockwise
? FSpot.Utils.PixbufUtils.Rotate90 (tag.Orientation)
: FSpot.Utils.PixbufUtils.Rotate270 (tag.Orientation);
tag.Orientation = orientation;
- metadata.Save ();
+ var always_sidecar = Preferences.Get<bool> (Preferences.METADATA_ALWAYS_USE_SIDECAR);
+ metadata.SaveSafely (uri, always_sidecar);
+ XdgThumbnailSpec.RemoveThumbnail (uri);
}
} catch (Exception e) {
Log.DebugException (e);
diff --git a/src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs b/src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs
index 8db7ff6..c5551b3 100644
--- a/src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs
+++ b/src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs
@@ -21,7 +21,7 @@ namespace FSpot.Utils
// Parse file
var res = new GIOTagLibFileAbstraction () { Uri = uri };
- var sidecar_uri = uri.ReplaceExtension (".xmp");
+ var sidecar_uri = GetSidecarUri (uri);
var sidecar_res = new GIOTagLibFileAbstraction () { Uri = sidecar_uri };
TagLib.Image.File file = null;
@@ -47,5 +47,26 @@ namespace FSpot.Utils
return file;
}
+
+ public static void SaveSafely (this TagLib.Image.File metadata, SafeUri photo_uri, bool always_sidecar)
+ {
+ if (always_sidecar || !metadata.Writeable || metadata.PossiblyCorrupt) {
+ if (!always_sidecar && metadata.PossiblyCorrupt) {
+ Hyena.Log.WarningFormat ("Metadata of file {0} may be corrupt, refusing to write to it, falling back to XMP sidecar.", photo_uri);
+ }
+
+ var sidecar_res = new GIOTagLibFileAbstraction () { Uri = GetSidecarUri (photo_uri) };
+
+ metadata.SaveXmpSidecar (sidecar_res);
+ } else {
+ metadata.Save ();
+ }
+ }
+
+ public static SafeUri GetSidecarUri (SafeUri photo_uri)
+ {
+ // TODO: We might consider alternate namings here
+ return photo_uri.ReplaceExtension (".xmp");
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]