[ostree] prune: delete all cached summaries files
- From: Giuseppe Scrivano <gscrivano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] prune: delete all cached summaries files
- Date: Tue, 15 Mar 2016 08:49:51 +0000 (UTC)
commit cff4e48d02303d49c813c1d628fe73a13bc3f024
Author: Giuseppe Scrivano <gscrivan redhat com>
Date: Fri Mar 11 12:59:18 2016 +0100
prune: delete all cached summaries files
Signed-off-by: Giuseppe Scrivano <gscrivan redhat com>
src/libostree/ostree-repo-prune.c | 65 +++++++++++++++++++++++++++++++++++++
1 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/src/libostree/ostree-repo-prune.c b/src/libostree/ostree-repo-prune.c
index 166e67e..3384883 100644
--- a/src/libostree/ostree-repo-prune.c
+++ b/src/libostree/ostree-repo-prune.c
@@ -112,6 +112,68 @@ maybe_prune_loose_object (OtPruneData *data,
return ret;
}
+static gboolean
+_ostree_repo_prune_tmp (OstreeRepo *self,
+ GCancellable *cancellable,
+ GError **error)
+{
+ gboolean ret = FALSE;
+ g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
+ glnx_fd_close int fd = -1;
+
+ fd = glnx_opendirat_with_errno (self->repo_dir_fd, _OSTREE_SUMMARY_CACHE_PATH, FALSE);
+ if (fd < 0)
+ {
+ if (errno == ENOENT)
+ ret = TRUE;
+ else
+ glnx_set_error_from_errno (error);
+ goto out;
+ }
+
+ if (!glnx_dirfd_iterator_init_take_fd (dup (fd), &dfd_iter, error))
+ goto out;
+
+ while (TRUE)
+ {
+ size_t len;
+ gboolean has_sig_suffix = FALSE;
+ struct dirent *dent;
+
+ if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error))
+ goto out;
+
+ if (dent == NULL)
+ break;
+
+ len = strlen (dent->d_name);
+ if (len > 4 && g_strcmp0 (dent->d_name + len - 4, ".sig") == 0)
+ {
+ has_sig_suffix = TRUE;
+ dent->d_name[len - 4] = '\0';
+ }
+
+ if (!g_hash_table_contains (self->remotes, dent->d_name))
+ {
+ /* Restore the previous value to get the file name. */
+ if (has_sig_suffix)
+ dent->d_name[len - 4] = '.';
+
+ if (unlinkat (fd, dent->d_name, 0) < 0)
+ {
+ glnx_set_error_from_errno (error);
+ goto out;
+ }
+ }
+ }
+
+ ret = TRUE;
+
+ out:
+ return ret;
+}
+
+
/**
* ostree_repo_prune_static_deltas:
* @self: Repo
@@ -295,6 +357,9 @@ ostree_repo_prune (OstreeRepo *self,
if (!ostree_repo_prune_static_deltas (self, NULL, cancellable, error))
goto out;
+ if (!_ostree_repo_prune_tmp (self, cancellable, error))
+ goto out;
+
ret = TRUE;
*out_objects_total = (data.n_reachable_meta + data.n_unreachable_meta +
data.n_reachable_content + data.n_unreachable_content);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]