Show 40 quoted lines
> When the "files" ODB transaction cleans up a temporary packfile or
> ".keep" lockfile on an error path, any failure to unlink the file is
> silently ignored. A ".keep" file left behind this way prevents its
> packfile from ever being removed by housekeeping.
>
> Use `unlink_or_warn()` instead so that such failures are reported.
>
> Signed-off-by: Justin Tobler <jltobler@gmail.com>
> ---
> object-file.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/object-file.c b/object-file.c
> index 132aaab6f8..a9800143bd 100644
> --- a/object-file.c
> +++ b/object-file.c
> @@ -823,7 +823,7 @@ static void flush_packfile_transaction(struct odb_transaction_files *transaction
> if (state->nr_written == 0) {
> close(state->f->fd);
> free_hashfile(state->f);
> - unlink(state->pack_tmp_name);
> + unlink_or_warn(state->pack_tmp_name);
> goto clear_exit;
> } else if (state->nr_written == 1) {
> finalize_hashfile(state->f, hash, FSYNC_COMPONENT_PACK,
> @@ -1276,13 +1276,13 @@ static int write_pack_lockfile(struct odb_source *source, const char *pack_name,
> if (write_in_full(fd, contents.buf, contents.len) < 0) {
> ret = error_errno(_("unable to write '%s'"), lock_path.buf);
> close(fd);
> - unlink(lock_path.buf);
> + unlink_or_warn(lock_path.buf);
> goto out;
> }
>
> if (close(fd) < 0) {
> ret = error_errno(_("unable to close '%s'"), lock_path.buf);
> - unlink(lock_path.buf);
> + unlink_or_warn(lock_path.buf);
> goto out;
> }