[gnome-builder] flatpak: reap old builds from flatpak-builder/builds



commit df0d3a49a0b51edcaf0b9189a4d79d4942ef256e
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jan 23 13:14:45 2018 -0800

    flatpak: reap old builds from flatpak-builder/builds
    
    We want to free up disk space from old builds that aren't doing us any
    favors by lingering around. So we can reap these at startup for anything
    older than 3 days.
    
    Sometimes it's helpful to dive into the directory to see why a build fails,
    but beyond a few days, I can't justify a reason to keep them around.

 src/plugins/flatpak/gbp-flatpak-application-addin.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/src/plugins/flatpak/gbp-flatpak-application-addin.c 
b/src/plugins/flatpak/gbp-flatpak-application-addin.c
index 83719c19b..44264c8ad 100644
--- a/src/plugins/flatpak/gbp-flatpak-application-addin.c
+++ b/src/plugins/flatpak/gbp-flatpak-application-addin.c
@@ -410,6 +410,8 @@ gbp_flatpak_application_addin_load (IdeApplicationAddin *addin,
                                     IdeApplication      *application)
 {
   GbpFlatpakApplicationAddin *self = (GbpFlatpakApplicationAddin *)addin;
+  g_autoptr(DzlDirectoryReaper) reaper = NULL;
+  g_autoptr(GFile) builds_dir = NULL;
 
   IDE_ENTRY;
 
@@ -421,6 +423,19 @@ gbp_flatpak_application_addin_load (IdeApplicationAddin *addin,
   gbp_flatpak_application_addin_remove_old_repo (self, NULL, NULL);
   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);
+
   IDE_EXIT;
 }
 


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