[gnome-photos/wip/uajain/side-car-file: 3/3] wip - attempt to delete edit file on discard all
- From: Umang Jain <uajain src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/uajain/side-car-file: 3/3] wip - attempt to delete edit file on discard all
- Date: Mon, 12 Feb 2018 13:26:48 +0000 (UTC)
commit 7f99c518f223713d94e6c8759f723dfe37e0efe2
Author: Umang Jain <mailumangjain gmail com>
Date: Mon Feb 12 18:25:56 2018 +0530
wip - attempt to delete edit file on discard all
This needs fixing, as the expected result is not yet observed.
The edit-file is not getting deleted. Maybe it's getting re-created
with photos_base_item_process_async? Needs fixing.
src/photos-base-item.c | 33 ++++++++++++++++++++++++++++++++-
src/photos-pipeline.c | 12 ++++++++++++
src/photos-pipeline.h | 2 ++
3 files changed, 46 insertions(+), 1 deletion(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 0f39805e..2c183d5b 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -1342,6 +1342,33 @@ photos_base_item_process_finish (PhotosBaseItem *self, GAsyncResult *res, GError
}
+static void
+photos_base_item_pipeline_reverted_to_original (GObject *source_object, GAsyncResult *res, gpointer
user_data)
+{
+ PhotosBaseItem *self = PHOTOS_BASE_ITEM (source_object);
+ g_autoptr (GTask) task = G_TASK (user_data);
+ PhotosPipeline *pipeline = PHOTOS_PIPELINE (g_task_get_task_data (task));
+
+ {
+ g_autoptr (GError) error = NULL;
+
+ if (!photos_base_item_process_finish (self, res, &error))
+ {
+ g_task_return_error (task, g_steal_pointer (&error));
+ goto out;
+ }
+ }
+
+ /* Even if deleting serialized edit file fails, let's not fail the task */
+ photos_pipeline_file_delete_async (pipeline);
+
+ g_task_return_boolean (task, TRUE);
+
+ out:
+ return;
+}
+
+
static void
photos_base_item_common_process (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
@@ -4080,6 +4107,7 @@ photos_base_item_pipeline_revert_to_original_async (PhotosBaseItem *self,
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, photos_base_item_pipeline_revert_to_original_async);
+ g_task_set_task_data (task, g_object_ref (pipeline), g_object_unref);
if (priv->edit_graph == NULL)
{
@@ -4087,7 +4115,10 @@ photos_base_item_pipeline_revert_to_original_async (PhotosBaseItem *self,
goto out;
}
- photos_base_item_process_async (self, cancellable, photos_base_item_common_process, g_object_ref (task));
+ photos_base_item_process_async (self,
+ cancellable,
+ photos_base_item_pipeline_reverted_to_original,
+ g_object_ref (task));
out:
return;
diff --git a/src/photos-pipeline.c b/src/photos-pipeline.c
index 1ba6d391..4ee03c34 100644
--- a/src/photos-pipeline.c
+++ b/src/photos-pipeline.c
@@ -756,3 +756,15 @@ photos_pipeline_snapshot (PhotosPipeline *self)
self->snapshot = gegl_node_to_xml_full (self->graph, self->graph, "/");
photos_debug (PHOTOS_DEBUG_GEGL, "Snapshot: %s", self->snapshot);
}
+
+
+void
+photos_pipeline_file_delete_async (PhotosPipeline *self)
+{
+ g_autoptr (GFile) file = NULL;
+
+ g_return_if_fail (PHOTOS_IS_PIPELINE (self));
+
+ file = g_file_new_for_uri (self->uri);
+ g_file_delete_async (file, G_PRIORITY_DEFAULT, NULL, NULL, NULL);
+}
diff --git a/src/photos-pipeline.h b/src/photos-pipeline.h
index 61a6e589..71b088b4 100644
--- a/src/photos-pipeline.h
+++ b/src/photos-pipeline.h
@@ -53,6 +53,8 @@ gboolean photos_pipeline_get_valist (PhotosPipeline *self,
const gchar *first_property_name,
va_list ap) G_GNUC_WARN_UNUSED_RESULT;
+void photos_pipeline_file_delete_async (PhotosPipeline *self);
+
GeglNode *photos_pipeline_get_graph (PhotosPipeline *self);
GeglNode *photos_pipeline_get_output (PhotosPipeline *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]