[ostree] repo: Only delete temp files older than a day
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] repo: Only delete temp files older than a day
- Date: Wed, 2 Oct 2013 22:18:13 +0000 (UTC)
commit f9379b0ce3ff26c66c090f586efa644cbf47609f
Author: Colin Walters <walters verbum org>
Date: Wed Oct 2 09:00:10 2013 -0400
repo: Only delete temp files older than a day
This is somewhat lame, but to do better we need a reliable
multiprocess synchronization mechanism.
https://bugzilla.gnome.org/show_bug.cgi?id=709115
src/libostree/ostree-repo-commit.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c
index eb09532..6a4ceb7 100644
--- a/src/libostree/ostree-repo-commit.c
+++ b/src/libostree/ostree-repo-commit.c
@@ -621,18 +621,23 @@ cleanup_tmpdir (OstreeRepo *self,
{
gboolean ret = FALSE;
gs_unref_object GFileEnumerator *enumerator = NULL;
+ guint64 curtime_secs;
- enumerator = g_file_enumerate_children (self->tmp_dir, "standard::name",
+ enumerator = g_file_enumerate_children (self->tmp_dir, "standard::name,time::modified",
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
cancellable,
error);
if (!enumerator)
goto out;
+ curtime_secs = g_get_real_time () / 1000000;
+
while (TRUE)
{
GFileInfo *file_info;
GFile *path;
+ guint64 mtime;
+ guint64 delta;
if (!gs_file_enumerator_iterate (enumerator, &file_info, &path,
cancellable, error))
@@ -640,8 +645,20 @@ cleanup_tmpdir (OstreeRepo *self,
if (file_info == NULL)
break;
- if (!gs_shutil_rm_rf (path, cancellable, error))
- goto out;
+ mtime = g_file_info_get_attribute_uint64 (file_info, "time::modified");
+ if (mtime > curtime_secs)
+ continue;
+ /* Only delete files older than a day. To do better, we would
+ * need to coordinate between multiple processes in a reliable
+ * fashion. See
+ * https://bugzilla.gnome.org/show_bug.cgi?id=709115
+ */
+ delta = curtime_secs - mtime;
+ if (delta > 60*60*24)
+ {
+ if (!gs_shutil_rm_rf (path, cancellable, error))
+ goto out;
+ }
}
ret = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]