[gnome-builder] unsaved-file: plumb cancellable into file replace
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] unsaved-file: plumb cancellable into file replace
- Date: Wed, 27 Jan 2016 07:16:12 +0000 (UTC)
commit 09f3b8d5e582e87b962dc7d4c66621b8f24dc0f5
Author: Christian Hergert <chergert redhat com>
Date: Wed Jan 27 07:30:55 2016 +0100
unsaved-file: plumb cancellable into file replace
By using g_file_replace_contents(), we can plumb a GCancellable into the
operation to allow for cancellations.
Fixes TODO item.
libide/ide-unsaved-file.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/libide/ide-unsaved-file.c b/libide/ide-unsaved-file.c
index a0fe0b9..6fe054c 100644
--- a/libide/ide-unsaved-file.c
+++ b/libide/ide-unsaved-file.c
@@ -67,6 +67,7 @@ ide_unsaved_file_persist (IdeUnsavedFile *self,
GCancellable *cancellable,
GError **error)
{
+ g_autoptr(GFile) file = NULL;
gboolean ret;
IDE_ENTRY;
@@ -76,14 +77,16 @@ ide_unsaved_file_persist (IdeUnsavedFile *self,
IDE_TRACE_MSG ("Saving draft to \"%s\"", self->temp_path);
- /*
- * TODO: Support cancellable.
- */
-
- ret = g_file_set_contents (self->temp_path,
- g_bytes_get_data (self->content, NULL),
- g_bytes_get_size (self->content),
- error);
+ file = g_file_new_for_path (self->temp_path);
+ ret = g_file_replace_contents (file,
+ g_bytes_get_data (self->content, NULL),
+ g_bytes_get_size (self->content),
+ NULL,
+ FALSE,
+ G_FILE_CREATE_REPLACE_DESTINATION,
+ NULL,
+ cancellable,
+ error);
IDE_RETURN (ret);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]