[gnome-builder] settings: add toggle to clear caches at startup
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] settings: add toggle to clear caches at startup
- Date: Wed, 12 Sep 2018 11:55:16 +0000 (UTC)
commit 604b61a3b0b966e5c94f485b548b22545b64905d
Author: Christian Hergert <chergert redhat com>
Date: Mon Sep 10 11:57:53 2018 -0700
settings: add toggle to clear caches at startup
This adds a new gsetting that can be used to clear caches at startup. This
might be useful if you don't want to burn disk cycles while getting your
project loaded. You'll need to manually purge caches in that case.
data/gsettings/org.gnome.builder.gschema.xml | 5 +++
src/libide/preferences/ide-preferences-builtin.c | 2 ++
.../flatpak/gbp-flatpak-application-addin.c | 41 ++++++++++++++--------
3 files changed, 34 insertions(+), 14 deletions(-)
---
diff --git a/data/gsettings/org.gnome.builder.gschema.xml b/data/gsettings/org.gnome.builder.gschema.xml
index 1cc69e2c2..e687d3baf 100644
--- a/data/gsettings/org.gnome.builder.gschema.xml
+++ b/data/gsettings/org.gnome.builder.gschema.xml
@@ -43,5 +43,10 @@
<summary>Show Open Files</summary>
<description>Display the open files list in the project sidebar.</description>
</key>
+ <key name="clear-cache-at-startup" type="b">
+ <default>true</default>
+ <summary>Clear build caches at startup</summary>
+ <description>If enabled, Builder will clear build caches upon startup.</description>
+ </key>
</schema>
</schemalist>
diff --git a/src/libide/preferences/ide-preferences-builtin.c
b/src/libide/preferences/ide-preferences-builtin.c
index 919ec0a1b..24499af29 100644
--- a/src/libide/preferences/ide-preferences-builtin.c
+++ b/src/libide/preferences/ide-preferences-builtin.c
@@ -408,6 +408,8 @@ ide_preferences_builtin_register_build (DzlPreferences *preferences)
g_signal_connect (widget, "input", G_CALLBACK (workers_input), NULL);
g_signal_connect (widget, "output", G_CALLBACK (workers_output), NULL);
+ dzl_preferences_add_switch (preferences, "build", "basic", "org.gnome.builder", "clear-cache-at-startup",
NULL, NULL, _("Clear build cache at startup"), _("Expired caches will be purged when Builder is started"),
NULL, 10);
+
dzl_preferences_add_list_group (preferences, "build", "network", _("Network"), GTK_SELECTION_NONE, 100);
dzl_preferences_add_switch (preferences, "build", "network", "org.gnome.builder.build",
"allow-network-when-metered", NULL, NULL, _("Allow downloads over metered connections"), _("Allow the use of
metered network connections when automatically downloading dependencies"), NULL, 10);
}
diff --git a/src/plugins/flatpak/gbp-flatpak-application-addin.c
b/src/plugins/flatpak/gbp-flatpak-application-addin.c
index 040b20e04..459160cdc 100644
--- a/src/plugins/flatpak/gbp-flatpak-application-addin.c
+++ b/src/plugins/flatpak/gbp-flatpak-application-addin.c
@@ -384,8 +384,7 @@ gbp_flatpak_application_addin_load (IdeApplicationAddin *addin,
IdeApplication *application)
{
GbpFlatpakApplicationAddin *self = (GbpFlatpakApplicationAddin *)addin;
- g_autoptr(DzlDirectoryReaper) reaper = NULL;
- g_autoptr(GFile) builds_dir = NULL;
+ g_autoptr(GSettings) settings = NULL;
IDE_ENTRY;
@@ -396,18 +395,32 @@ gbp_flatpak_application_addin_load (IdeApplicationAddin *addin,
gbp_flatpak_application_addin_reload (self);
- /*
- * Cleanup old build data to avoid an ever-growing cache directory.
- * Any build data older than 3 days can be wiped.
- */
- reaper = dzl_directory_reaper_new ();
- builds_dir = g_file_new_build_filename (g_get_user_cache_dir (),
- ide_get_program_name (),
- "flatpak-builder",
- "build",
- NULL);
- dzl_directory_reaper_add_directory (reaper, builds_dir, G_TIME_SPAN_DAY * 3);
- dzl_directory_reaper_execute_async (reaper, NULL, NULL, NULL);
+ settings = g_settings_new ("org.gnome.builder");
+
+ if (g_settings_get_boolean (settings, "clear-cache-at-startup"))
+ {
+ g_autoptr(DzlDirectoryReaper) reaper = NULL;
+ g_autoptr(GFile) builds_dir = NULL;
+ g_autofree gchar *path = NULL;
+
+ path = g_build_filename (g_get_user_cache_dir (),
+ ide_get_program_name (),
+ "flatpak-builder",
+ "build",
+ NULL);
+
+ IDE_TRACE_MSG ("Clearing flatpak build cache \"%s\"", path);
+
+ /*
+ * Cleanup old build data to avoid an ever-growing cache directory.
+ * Any build data older than 3 days can be wiped.
+ */
+
+ reaper = dzl_directory_reaper_new ();
+ builds_dir = g_file_new_for_path (path);
+ dzl_directory_reaper_add_directory (reaper, builds_dir, G_TIME_SPAN_DAY * 3);
+ dzl_directory_reaper_execute_async (reaper, NULL, NULL, NULL);
+ }
IDE_EXIT;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]