From 7610f0ccff8c6ab334a32105175659adcb5a7f08 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Tue, 19 May 2015 15:45:51 -0700 Subject: [PATCH] repo: Delete compat files with commit 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 --- src/libostree/ostree-repo.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index 1c951b127..ffb2e630a 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -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))