flatpak-prune.c (flatpak-1.15.1.tar.xz) | : | flatpak-prune.c (flatpak-1.15.2.tar.xz) | ||
---|---|---|---|---|
skipping to change at line 518 | skipping to change at line 518 | |||
{ | { | |||
g_autoptr(GVariant) extra_commitmeta = NULL; | g_autoptr(GVariant) extra_commitmeta = NULL; | |||
g_autoptr(GVariant) commit_reachable = NULL; | g_autoptr(GVariant) commit_reachable = NULL; | |||
FlatpakOstreeObjectName commit_name; | FlatpakOstreeObjectName commit_name; | |||
/* Early bail-out if we already scanned this commit in the first phase (or via some other branch) */ | /* Early bail-out if we already scanned this commit in the first phase (or via some other branch) */ | |||
flatpak_ostree_object_name_serialize (&commit_name, checksum, OSTREE_OBJEC T_TYPE_COMMIT); | flatpak_ostree_object_name_serialize (&commit_name, checksum, OSTREE_OBJEC T_TYPE_COMMIT); | |||
if (object_name_bag_contains (reachable, &commit_name)) | if (object_name_bag_contains (reachable, &commit_name)) | |||
continue; | continue; | |||
flatpak_debug2 ("Finding objects to keep for commit %s", checksum); | g_debug ("Finding objects to keep for commit %s", checksum); | |||
if (!load_extra_commitmeta (repo, checksum, &extra_commitmeta, cancellable , error)) | if (!load_extra_commitmeta (repo, checksum, &extra_commitmeta, cancellable , error)) | |||
return FALSE; | return FALSE; | |||
if (extra_commitmeta) | if (extra_commitmeta) | |||
commit_reachable = g_variant_lookup_value (extra_commitmeta, "xa.reachab le", G_VARIANT_TYPE ("a" FLATPAK_OSTREE_OBJECT_NAME_ELEMENT_TYPE)); | commit_reachable = g_variant_lookup_value (extra_commitmeta, "xa.reachab le", G_VARIANT_TYPE ("a" FLATPAK_OSTREE_OBJECT_NAME_ELEMENT_TYPE)); | |||
if (commit_reachable == NULL) | if (commit_reachable == NULL) | |||
{ | { | |||
g_autoptr(GHashTable) commit_reachable_ht = reachable_commits_new (); | g_autoptr(GHashTable) commit_reachable_ht = reachable_commits_new (); | |||
skipping to change at line 609 | skipping to change at line 609 | |||
static gboolean | static gboolean | |||
prune_loose_object (OtPruneData *data, | prune_loose_object (OtPruneData *data, | |||
const char *checksum, | const char *checksum, | |||
OstreeObjectType objtype, | OstreeObjectType objtype, | |||
GCancellable *cancellable, | GCancellable *cancellable, | |||
GError **error) | GError **error) | |||
{ | { | |||
guint64 storage_size = 0; | guint64 storage_size = 0; | |||
flatpak_debug2 ("Pruning unneeded object %s.%s", checksum, | g_debug ("Pruning unneeded object %s.%s", checksum, | |||
ostree_object_type_to_string (objtype)); | ostree_object_type_to_string (objtype)); | |||
if (!ostree_repo_query_object_storage_size (data->repo, objtype, checksum, | if (!ostree_repo_query_object_storage_size (data->repo, objtype, checksum, | |||
&storage_size, cancellable, error) ) | &storage_size, cancellable, error) ) | |||
return FALSE; | return FALSE; | |||
data->freed_bytes += storage_size; | data->freed_bytes += storage_size; | |||
data->n_unreachable++; | data->n_unreachable++; | |||
if (!data->dont_prune) | if (!data->dont_prune) | |||
{ | { | |||
skipping to change at line 768 | skipping to change at line 768 | |||
} | } | |||
{ | { | |||
/* shared lock in this region, see locking strategy above */ | /* shared lock in this region, see locking strategy above */ | |||
glnx_autofd int lock_fd = -1; | glnx_autofd int lock_fd = -1; | |||
if (!get_repo_lock (repo, LOCK_SH, &lock_fd, cancellable, error)) | if (!get_repo_lock (repo, LOCK_SH, &lock_fd, cancellable, error)) | |||
return FALSE; | return FALSE; | |||
timer = g_timer_new (); | timer = g_timer_new (); | |||
g_debug ("Finding reachable objects, unlocked (depth=%d)", depth); | g_info ("Finding reachable objects, unlocked (depth=%d)", depth); | |||
g_timer_start (timer); | g_timer_start (timer); | |||
if (!traverse_reachable_refs_unlocked (repo, depth, reachable, cancellable, error)) | if (!traverse_reachable_refs_unlocked (repo, depth, reachable, cancellable, error)) | |||
return FALSE; | return FALSE; | |||
g_timer_stop (timer); | g_timer_stop (timer); | |||
g_debug ("Elapsed time: %.1f sec", g_timer_elapsed (timer, NULL)); | g_info ("Elapsed time: %.1f sec", g_timer_elapsed (timer, NULL)); | |||
} | } | |||
{ | { | |||
/* exclusive lock in this region, see locking strategy above */ | /* exclusive lock in this region, see locking strategy above */ | |||
glnx_autofd int lock_fd = -1; | glnx_autofd int lock_fd = -1; | |||
if (!get_repo_lock (repo, LOCK_EX, &lock_fd, cancellable, error)) | if (!get_repo_lock (repo, LOCK_EX, &lock_fd, cancellable, error)) | |||
return FALSE; | return FALSE; | |||
timer = g_timer_new (); | timer = g_timer_new (); | |||
g_debug ("Finding reachable objects, locked (depth=%d)", depth); | g_info ("Finding reachable objects, locked (depth=%d)", depth); | |||
g_timer_start (timer); | g_timer_start (timer); | |||
if (!traverse_reachable_refs_unlocked (repo, depth, reachable, cancellable, error)) | if (!traverse_reachable_refs_unlocked (repo, depth, reachable, cancellable, error)) | |||
return FALSE; | return FALSE; | |||
data.repo = repo; | data.repo = repo; | |||
data.reachable = reachable; | data.reachable = reachable; | |||
data.dont_prune = dry_run; | data.dont_prune = dry_run; | |||
g_timer_stop (timer); | g_timer_stop (timer); | |||
g_debug ("Elapsed time: %.1f sec", g_timer_elapsed (timer, NULL)); | g_info ("Elapsed time: %.1f sec", g_timer_elapsed (timer, NULL)); | |||
g_debug ("Pruning unreachable objects"); | g_info ("Pruning unreachable objects"); | |||
g_timer_start (timer); | g_timer_start (timer); | |||
if (!prune_unreachable_loose_objects (repo, &data, cancellable, error)) | if (!prune_unreachable_loose_objects (repo, &data, cancellable, error)) | |||
return FALSE; | return FALSE; | |||
g_timer_stop (timer); | g_timer_stop (timer); | |||
g_debug ("Elapsed time: %.1f sec", g_timer_elapsed (timer, NULL)); | g_info ("Elapsed time: %.1f sec", g_timer_elapsed (timer, NULL)); | |||
} | } | |||
/* Prune static deltas outside lock to avoid conflict with its exclusive lock */ | /* Prune static deltas outside lock to avoid conflict with its exclusive lock */ | |||
if (!dry_run) | if (!dry_run) | |||
{ | { | |||
g_debug ("Pruning static deltas"); | g_info ("Pruning static deltas"); | |||
g_timer_start (timer); | g_timer_start (timer); | |||
if (!ostree_repo_prune_static_deltas (repo, NULL, cancellable, error)) | if (!ostree_repo_prune_static_deltas (repo, NULL, cancellable, error)) | |||
return FALSE; | return FALSE; | |||
g_timer_stop (timer); | g_timer_stop (timer); | |||
g_debug ("Elapsed time: %.1f sec", g_timer_elapsed (timer, NULL)); | g_info ("Elapsed time: %.1f sec", g_timer_elapsed (timer, NULL)); | |||
} | } | |||
*out_objects_total = data.n_reachable + data.n_unreachable; | *out_objects_total = data.n_reachable + data.n_unreachable; | |||
*out_objects_pruned = data.n_unreachable; | *out_objects_pruned = data.n_unreachable; | |||
*out_pruned_object_size_total = data.freed_bytes; | *out_pruned_object_size_total = data.freed_bytes; | |||
return TRUE; | return TRUE; | |||
} | } | |||
End of changes. 10 change blocks. | ||||
11 lines changed or deleted | 11 lines changed or added |