Skip to content

Commit

Permalink
repo: Delete compat files with commit
Browse files Browse the repository at this point in the history
Like the detached metadata, delete the compat sizes and signature files
if they exist when deleting a commit object.

[endlessm/eos-shell#5083]

Rebase 2016.9: Switch to glnx_set_error_from_errno
Rebase 2016.15 (T14427): Merge error conditions to single check and
  prefix the error with the failed file
Rebase 2017.12 (T18936): Rework to use ot_ensure_unlinked_at()
Rebase 2018.4 (T17367, T22022): Inline compat file loose path calculation
  • Loading branch information
dbnicholson committed Mar 16, 2021
1 parent 3e289b1 commit 7610f0c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/libostree/ostree-repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4260,6 +4260,26 @@ ostree_repo_delete_object (OstreeRepo *self,

if (!ot_ensure_unlinked_at (self->objects_dir_fd, meta_loose, error))
return FALSE;

/* Delete optional compat objects */
const char compat_files_exts[][7] = { "sig", "sizes2" };
for (gsize i = 0; i < G_N_ELEMENTS (compat_files_exts); i++)
{
const char *ext = compat_files_exts[i];
char *buf = meta_loose;

/* Write the compat object loose name manually since there's no
* loose path API that handles arbitrary file extensions
*/
*buf = sha256[0];
buf++;
*buf = sha256[1];
buf++;
snprintf (buf, _OSTREE_LOOSE_PATH_MAX - 2, "/%s.%s", sha256 + 2, ext);

if (!ot_ensure_unlinked_at (self->objects_dir_fd, meta_loose, error))
return FALSE;
}
}

if (!glnx_unlinkat (self->objects_dir_fd, loose_path, 0, error))
Expand Down

0 comments on commit 7610f0c

Please sign in to comment.