[gnome-builder] autotools: reap old makecache entries at startup
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] autotools: reap old makecache entries at startup
- Date: Thu, 13 Oct 2016 23:28:55 +0000 (UTC)
commit c47c8d91886256bd1fdb5cd08839ed0fa7d0caa5
Author: Christian Hergert <chergert redhat com>
Date: Thu Oct 13 16:28:29 2016 -0700
autotools: reap old makecache entries at startup
This will help cleanup the .cache/gnome-builder/makecache/ directory from
stale makecache entries that could have been lingered from a crash or
other reasons.
plugins/autotools/Makefile.am | 2 +
plugins/autotools/autotools-plugin.c | 2 +
.../autotools/ide-autotools-application-addin.c | 106 ++++++++++++++++++++
.../autotools/ide-autotools-application-addin.h | 32 ++++++
4 files changed, 142 insertions(+), 0 deletions(-)
---
diff --git a/plugins/autotools/Makefile.am b/plugins/autotools/Makefile.am
index 24481ad..09e4ebb 100644
--- a/plugins/autotools/Makefile.am
+++ b/plugins/autotools/Makefile.am
@@ -6,6 +6,8 @@ dist_plugin_DATA = autotools.plugin
libautotools_plugin_la_SOURCES = \
autotools-plugin.c \
+ ide-autotools-application-addin.c \
+ ide-autotools-application-addin.h \
ide-autotools-builder.c \
ide-autotools-builder.h \
ide-autotools-build-system.c \
diff --git a/plugins/autotools/autotools-plugin.c b/plugins/autotools/autotools-plugin.c
index cc26daf..9e15698 100644
--- a/plugins/autotools/autotools-plugin.c
+++ b/plugins/autotools/autotools-plugin.c
@@ -19,12 +19,14 @@
#include <libpeas/peas.h>
#include <ide.h>
+#include "ide-autotools-application-addin.h"
#include "ide-autotools-build-system.h"
#include "ide-autotools-project-miner.h"
void
peas_register_types (PeasObjectModule *module)
{
+ peas_object_module_register_extension_type (module, IDE_TYPE_APPLICATION_ADDIN,
IDE_TYPE_AUTOTOOLS_APPLICATION_ADDIN);
peas_object_module_register_extension_type (module, IDE_TYPE_BUILD_SYSTEM,
IDE_TYPE_AUTOTOOLS_BUILD_SYSTEM);
peas_object_module_register_extension_type (module, IDE_TYPE_PROJECT_MINER,
IDE_TYPE_AUTOTOOLS_PROJECT_MINER);
}
diff --git a/plugins/autotools/ide-autotools-application-addin.c
b/plugins/autotools/ide-autotools-application-addin.c
new file mode 100644
index 0000000..51917fd
--- /dev/null
+++ b/plugins/autotools/ide-autotools-application-addin.c
@@ -0,0 +1,106 @@
+/* ide-autotools-application-addin.c
+ *
+ * Copyright (C) 2016 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define G_LOG_DOMAIN "ide-autotools-application-addin"
+
+#include "ide-autotools-application-addin.h"
+
+struct _IdeAutotoolsApplicationAddin
+{
+ GObject parent_instance;
+};
+
+static void
+ide_autotools_application_addin_load (IdeApplicationAddin *addin,
+ IdeApplication *application)
+{
+ g_autofree gchar *path = NULL;
+ g_autoptr(GFile) file = NULL;
+ g_autoptr(GFileEnumerator) enumerator = NULL;
+ gpointer infoptr;
+ GTimeVal now;
+
+ g_assert (IDE_IS_AUTOTOOLS_APPLICATION_ADDIN (addin));
+ g_assert (IDE_IS_APPLICATION (application));
+
+ path = g_build_filename (g_get_user_cache_dir (),
+ "gnome-builder",
+ "makecache",
+ NULL);
+ file = g_file_new_for_path (path);
+
+ enumerator = g_file_enumerate_children (file,
+ G_FILE_ATTRIBUTE_STANDARD_NAME,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL);
+
+ if (enumerator == NULL)
+ return;
+
+ g_get_current_time (&now);
+
+ while (NULL != (infoptr = g_file_enumerator_next_file (enumerator, NULL, NULL)))
+ {
+ g_autoptr(GFileInfo) info = infoptr;
+ const gchar *name = g_file_info_get_name (info);
+ const gchar *suffix = strrchr (name, '.');
+
+ if (suffix && g_str_has_prefix (suffix, ".tmp-"))
+ {
+ gint64 time_at;
+
+ suffix += IDE_LITERAL_LENGTH (".tmp-");
+ time_at = g_ascii_strtoll (suffix, NULL, 10);
+
+ if (time_at == G_MININT64 || time_at == G_MAXINT64)
+ continue;
+
+ if (time_at + 60 < now.tv_sec)
+ {
+ g_autoptr(GFile) child = NULL;
+
+ child = g_file_get_child (file, name);
+ g_file_delete (child, NULL, NULL);
+ }
+ }
+ }
+}
+
+static void
+application_addin_iface_init (IdeApplicationAddinInterface *iface)
+{
+ iface->load = ide_autotools_application_addin_load;
+}
+
+G_DEFINE_TYPE_EXTENDED (IdeAutotoolsApplicationAddin,
+ ide_autotools_application_addin,
+ G_TYPE_OBJECT,
+ 0,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_APPLICATION_ADDIN,
+ application_addin_iface_init))
+
+static void
+ide_autotools_application_addin_class_init (IdeAutotoolsApplicationAddinClass *klass)
+{
+}
+
+static void
+ide_autotools_application_addin_init (IdeAutotoolsApplicationAddin *self)
+{
+}
diff --git a/plugins/autotools/ide-autotools-application-addin.h
b/plugins/autotools/ide-autotools-application-addin.h
new file mode 100644
index 0000000..82afaeb
--- /dev/null
+++ b/plugins/autotools/ide-autotools-application-addin.h
@@ -0,0 +1,32 @@
+/* ide-autotools-application-addin.h
+ *
+ * Copyright (C) 2016 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_AUTOTOOLS_APPLICATION_ADDIN_H
+#define IDE_AUTOTOOLS_APPLICATION_ADDIN_H
+
+#include <ide.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_AUTOTOOLS_APPLICATION_ADDIN (ide_autotools_application_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeAutotoolsApplicationAddin, ide_autotools_application_addin, IDE,
AUTOTOOLS_APPLICATION_ADDIN, GObject)
+
+G_END_DECLS
+
+#endif /* IDE_AUTOTOOLS_APPLICATION_ADDIN_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]