[gnome-photos/wip/rishi/thumbnailer: 15/15] base-item: Refresh the thumbnail whenever the pipeline is saved
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/thumbnailer: 15/15] base-item: Refresh the thumbnail whenever the pipeline is saved
- Date: Wed, 22 Feb 2017 19:37:50 +0000 (UTC)
commit c322fb6d501ad114fa114d49bb305513468b9fb6
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Feb 22 20:16:12 2017 +0100
base-item: Refresh the thumbnail whenever the pipeline is saved
There is no surety about an ongoing thumbnailing operation. Hence,
only cancelling the GCancellable isn't enough. A separate attempt must
be made to delete the old thumbnail.
https://bugzilla.gnome.org/show_bug.cgi?id=763329
src/photos-base-item.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 59 insertions(+), 1 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 33c3a42..cfe7061 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -1578,16 +1578,62 @@ photos_base_item_metadata_add_shared_in_thread_func (GTask *task,
static void
+photos_base_item_pipeline_save_delete (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ PhotosBaseItem *self;
+ PhotosBaseItemPrivate *priv;
+ GError *error;
+ GFile *thumbnail_file = G_FILE (source_object);
+ GTask *task = G_TASK (user_data);
+
+ self = PHOTOS_BASE_ITEM (g_task_get_source_object (task));
+ priv = photos_base_item_get_instance_private (self);
+
+ error = NULL;
+ if (!g_file_delete_finish (thumbnail_file, res, &error))
+ {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+ {
+ gchar *uri = NULL;
+
+ uri = g_file_get_uri (thumbnail_file);
+ g_warning ("Unable to delete thumbnail %s: %s", uri, error->message);
+ g_free (uri);
+ }
+
+ g_error_free (error);
+ }
+
+ /* Mark the task as a success, no matter what. The pipeline has
+ * already been saved, so it doesn't make sense to fail the task
+ * just because we failed to delete the old thumbnail.
+ */
+
+ g_message ("refreshing again");
+ g_clear_pointer (&priv->thumb_path, g_free);
+ photos_base_item_refresh (self);
+ g_task_return_boolean (task, TRUE);
+
+ g_object_unref (task);
+}
+
+
+static void
photos_base_item_pipeline_save_save (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
GTask *task = G_TASK (user_data);
PhotosBaseItem *self;
PhotosBaseItemPrivate *priv;
+ GCancellable *cancellable;
GError *error;
+ GFile *thumbnail_file = NULL;
+ gchar *thumbnail_path = NULL;
self = PHOTOS_BASE_ITEM (g_task_get_source_object (task));
priv = photos_base_item_get_instance_private (self);
+ cancellable = g_task_get_cancellable (task);
+
error = NULL;
if (!photos_pipeline_save_finish (priv->pipeline, res, &error))
{
@@ -1595,9 +1641,21 @@ photos_base_item_pipeline_save_save (GObject *source_object, GAsyncResult *res,
goto out;
}
- g_task_return_boolean (task, TRUE);
+ g_cancellable_cancel (priv->cancellable);
+ g_clear_object (&priv->cancellable);
+ priv->cancellable = g_cancellable_new ();
+
+ thumbnail_path = photos_utils_get_thumbnail_path_for_uri (priv->uri);
+ thumbnail_file = g_file_new_for_path (thumbnail_path);
+ g_file_delete_async (thumbnail_file,
+ G_PRIORITY_DEFAULT,
+ cancellable,
+ photos_base_item_pipeline_save_delete,
+ g_object_ref (task));
out:
+ g_free (thumbnail_path);
+ g_clear_object (&thumbnail_file);
g_object_unref (task);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]