[f-spot/taglib-metadata: 11/29] Remove the home-made safe-writing pattern.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot/taglib-metadata: 11/29] Remove the home-made safe-writing pattern.
- Date: Fri, 2 Jul 2010 09:46:20 +0000 (UTC)
commit dd0bf98dc858b28feba6f409e25130ef06c3ec44
Author: Ruben Vermeersch <ruben savanne be>
Date: Tue Jun 15 21:15:33 2010 +0200
Remove the home-made safe-writing pattern.
The file abstraction now handles that.
src/Jobs/SyncMetadataJob.cs | 9 ++++-----
src/RotateCommand.cs | 27 +--------------------------
2 files changed, 5 insertions(+), 31 deletions(-)
---
diff --git a/src/Jobs/SyncMetadataJob.cs b/src/Jobs/SyncMetadataJob.cs
index 48bf580..653dc7c 100644
--- a/src/Jobs/SyncMetadataJob.cs
+++ b/src/Jobs/SyncMetadataJob.cs
@@ -43,7 +43,6 @@ namespace FSpot.Jobs {
return false;
}
- //FIXME: Won't work on non-file uris
void WriteMetadataToImage (Photo photo)
{
string path = photo.DefaultVersion.Uri.LocalPath;
@@ -54,19 +53,19 @@ namespace FSpot.Jobs {
for (int i = 0; i < tags.Length; i++)
names [i] = tags [i].Name;
- //var res = new GIOTagLibFileAbstraction () { Uri = photo.DefaultVersion.Uri };
- var res = photo.DefaultVersion.Uri.AbsolutePath;
+ var res = new GIOTagLibFileAbstraction () { Uri = photo.DefaultVersion.Uri };
using (var metadata = TagLib.File.Create (res) as TagLib.Image.File) {
metadata.GetTag (TagLib.TagTypes.XMP, true);
var tag = metadata.ImageTag;
tag.DateTime = photo.Time;
- tag.Comment = photo.Description;
+ tag.Comment = photo.Description ?? String.Empty;
tag.Keywords = names;
tag.Rating = photo.Rating;
tag.Software = FSpot.Defines.PACKAGE + " version " + FSpot.Defines.VERSION;
- SaveMetaData (metadata, path);
+ Hyena.Log.Information (photo.DefaultVersion.Uri);
+ metadata.Save ();
}
}
}
diff --git a/src/RotateCommand.cs b/src/RotateCommand.cs
index 74b1e49..1126411 100644
--- a/src/RotateCommand.cs
+++ b/src/RotateCommand.cs
@@ -69,38 +69,13 @@ namespace FSpot {
: FSpot.Utils.PixbufUtils.Rotate270 (tag.Orientation);
tag.Orientation = orientation;
- SaveMetaData (metadata, original_path);
+ metadata.Save ();
}
} catch (Exception e) {
throw new RotateException (Catalog.GetString ("Unable to rotate this type of photo"), original_path);
}
}
- private static void SaveMetaData (TagLib.File image, string path)
- {
- // FIXME: This currently copies the file out to a tmp file, overwrites it
- // and restores the tmp file in case of failure. Should obviously be the
- // other way around, but Taglib# doesn't have an interface to do this.
- // https://bugzilla.gnome.org/show_bug.cgi?id=618768
-
- var uri = new SafeUri (path);
- var tmp = System.IO.Path.GetTempFileName ();
- var tmp_uri = new SafeUri (tmp);
-
- var orig_file = GLib.FileFactory.NewForUri (uri);
- var tmp_file = GLib.FileFactory.NewForUri (tmp_uri);
-
- tmp_file.Delete ();
- orig_file.Copy (tmp_file, GLib.FileCopyFlags.AllMetadata | GLib.FileCopyFlags.Overwrite, null, null);
-
- try {
- image.Save ();
- } catch (Exception e) {
- tmp_file.Copy (orig_file, GLib.FileCopyFlags.AllMetadata | GLib.FileCopyFlags.Overwrite, null, null);
- throw e;
- }
- }
-
private void Rotate (string original_path, RotateDirection dir)
{
RotateOrientation (original_path, dir);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]