[f-spot/stable-0.8] Use file.jpg.xmp, but fall back to file.xmp if it already exists.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot/stable-0.8] Use file.jpg.xmp, but fall back to file.xmp if it already exists.
- Date: Sun, 19 Dec 2010 11:23:48 +0000 (UTC)
commit 27c9686cfc27c1befbcfd03ba366a31258b3410f
Author: Ruben Vermeersch <ruben savanne be>
Date: Sun Dec 19 11:38:51 2010 +0100
Use file.jpg.xmp, but fall back to file.xmp if it already exists.
https://bugzilla.gnome.org/show_bug.cgi?id=624797
src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs b/src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs
index c5551b3..52d5769 100644
--- a/src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs
+++ b/src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs
@@ -63,10 +63,26 @@ namespace FSpot.Utils
}
}
+ private delegate SafeUri GenerateSideCarName (SafeUri photo_uri);
+ private static GenerateSideCarName[] SidecarNameGenerators = {
+ (p) => new SafeUri (p.AbsoluteUri + ".xmp"),
+ (p) => p.ReplaceExtension (".xmp"),
+ };
+
public static SafeUri GetSidecarUri (SafeUri photo_uri)
{
- // TODO: We might consider alternate namings here
- return photo_uri.ReplaceExtension (".xmp");
+ // First probe for existing sidecar files, use the one that's found.
+ foreach (var generator in SidecarNameGenerators) {
+ var name = generator (photo_uri);
+ var file = GLib.FileFactory.NewForUri (name);
+ if (file.Exists) {
+ return name;
+ }
+ }
+
+
+ // Fall back to the default strategy.
+ return SidecarNameGenerators[0] (photo_uri);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]