deltas: Prune deltas when the corresponding "to" commit vanishes
We want prune to actually give you back disk space when using deltas.
This commit is contained in:
1 parent
dbad2f6e19
commit
08476ce254
7 files changed
+86
-26
No files matched your search
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "ostree-core-private.h"
|
||||
#include "ostree-repo-private.h"
|
||||
#include "otutil.h"
|
||||
|
||||
@@ -212,6 +213,49 @@ ostree_repo_prune (OstreeRepo *self,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
{ gs_unref_ptrarray GPtrArray *deltas = NULL;
|
||||
guint i;
|
||||
|
||||
if (!ostree_repo_list_static_delta_names (self, &deltas,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
for (i = 0; i < deltas->len; i++)
|
||||
{
|
||||
const char *deltaname = deltas->pdata[i];
|
||||
const char *dash = strchr (deltaname, '-');
|
||||
const char *to = NULL;
|
||||
gboolean have_commit;
|
||||
gs_free char *from = NULL;
|
||||
gs_free char *deltadir = NULL;
|
||||
|
||||
if (!dash)
|
||||
{
|
||||
to = deltaname;
|
||||
}
|
||||
else
|
||||
{
|
||||
from = g_strndup (deltaname, dash - deltaname);
|
||||
to = dash + 1;
|
||||
}
|
||||
|
||||
if (!ostree_repo_has_object (self, OSTREE_OBJECT_TYPE_COMMIT,
|
||||
to, &have_commit,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (have_commit)
|
||||
continue;
|
||||
|
||||
deltadir = _ostree_get_relative_static_delta_path (from, to, NULL);
|
||||
|
||||
if (!gs_shutil_rm_rf_at (self->repo_dir_fd, deltadir,
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user