commit: 8165933c5b9986b536cf91b8ba82f7e76c9cc758 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Sun Dec 26 13:54:21 2021 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Sun Dec 26 13:54:21 2021 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8165933c
libq/move_file: remove source file when done move suggests the source is gone, so make sure it is :) Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> libq/move_file.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libq/move_file.c b/libq/move_file.c index 07cf69f..b98c8e2 100644 --- a/libq/move_file.c +++ b/libq/move_file.c @@ -85,7 +85,7 @@ move_file(int rootfd_src, const char *name_src, return -1; } - /* Preserve the file times */ + /* preserve the file times */ times[0] = get_stat_atime(&st); times[1] = get_stat_mtime(&st); futimens(fd_dst, times); @@ -93,12 +93,15 @@ move_file(int rootfd_src, const char *name_src, close(fd_src); close(fd_dst); - /* finally move the new tmp dst file to the right place, which + /* move the new tmp dst file to the right place, which * should be on the same FS/device now */ if (renameat(rootfd_dst, tmpname_dst, rootfd_dst, name_dst)) { warnp("could not rename %s to %s", tmpname_dst, name_dst); return -1; } + + /* finally remove the source file */ + return unlinkat(rootfd_src, name_src, 0); } return 0;