[gnome-builder] foundry: avoid symlinks for builddir path when possible



commit 390fd679ad6b3d94134d37c9adc47c9504c7d3d2
Author: Christian Hergert <chergert redhat com>
Date:   Tue Mar 26 18:47:42 2019 -0700

    foundry: avoid symlinks for builddir path when possible
    
    If we detect that we have a symlink in the path for the builddir
    (such as from xdg dirs), then it helps to remove that upfront.
    Otherwise, there is a good chance we'll fail to resolve things
    such as file paths.

 src/libide/foundry/ide-build-system.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/foundry/ide-build-system.c b/src/libide/foundry/ide-build-system.c
index e33d381a5..b3440d0da 100644
--- a/src/libide/foundry/ide-build-system.c
+++ b/src/libide/foundry/ide-build-system.c
@@ -23,11 +23,14 @@
 #include "config.h"
 
 #include <libide-code.h>
+#include <libide-io.h>
 #include <libide-projects.h>
 #include <libide-threading.h>
 #include <libide-vcs.h>
 #include <string.h>
 
+#include "ide-gfile-private.h"
+
 #include "ide-build-manager.h"
 #include "ide-pipeline.h"
 #include "ide-build-system.h"
@@ -465,6 +468,8 @@ ide_build_system_get_builddir (IdeBuildSystem   *self,
     {
       g_autofree gchar *name = NULL;
       g_autofree gchar *branch = NULL;
+      g_autoptr(GFile) base = NULL;
+      g_autoptr(GFile) nosymlink = NULL;
       IdeConfig *config;
       const gchar *config_id;
       const gchar *runtime_id;
@@ -487,7 +492,13 @@ ide_build_system_get_builddir (IdeBuildSystem   *self,
 
       g_strdelimit (name, "@:/ ", '-');
 
-      ret = ide_context_cache_filename (context, "builds", name, NULL);
+      /* Avoid symlink's when we can, so that paths with symlinks have at least
+       * a chance of working.
+       */
+      base = ide_context_cache_file (context, "builds", name, NULL);
+      nosymlink = _ide_g_file_readlink (base);
+
+      ret = g_file_get_path (nosymlink);
     }
 
   IDE_RETURN (ret);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]