[gnome-builder] buffers: create the directory tree before saving
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] buffers: create the directory tree before saving
- Date: Mon, 8 Oct 2018 06:48:34 +0000 (UTC)
commit c4c7572694defe43d3876d8e2f2b0f2ab23bfd93
Author: Christian Hergert <chergert redhat com>
Date: Sun Oct 7 23:38:48 2018 -0700
buffers: create the directory tree before saving
In case the user moved the directory out from under Builder, we should
recreate all of the directories needed to be able to save the file.
It would be nice to make this async in the future, but there is not
currently a variant of this API that is async.
Fixes #659
src/libide/buffers/ide-buffer-manager.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
---
diff --git a/src/libide/buffers/ide-buffer-manager.c b/src/libide/buffers/ide-buffer-manager.c
index fc969e8ec..2f37d38e9 100644
--- a/src/libide/buffers/ide-buffer-manager.c
+++ b/src/libide/buffers/ide-buffer-manager.c
@@ -1166,6 +1166,24 @@ ide_buffer_manager_save_file_async (IdeBufferManager *self,
IDE_EXIT;
}
+ /*
+ * In-case the directory for the file does not exist yet, or has been moved
+ * since we saved things locally, create the directory chain.
+ */
+ {
+ GFile *gfile = ide_file_get_file (file);
+ g_autoptr(GFile) parent = g_file_get_parent (gfile);
+ g_autoptr(GError) error = NULL;
+
+ /* It would be nice to do this async in the future... */
+ if (!g_file_make_directory_with_parents (parent, cancellable, &error) &&
+ !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
+ {
+ ide_task_return_error (task, g_steal_pointer (&error));
+ IDE_EXIT;
+ }
+ }
+
context = ide_object_get_context (IDE_OBJECT (self));
ide_context_hold_for_object (context, task);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]