prune: delete all cached summaries files
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
2bf84d7e5d
commit
cff4e48d02
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue