aboutsummaryrefslogtreecommitdiff
path: root/libq
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2021-12-26 14:54:21 +0100
committerFabian Groffen <grobian@gentoo.org>2021-12-26 14:54:21 +0100
commit8165933c5b9986b536cf91b8ba82f7e76c9cc758 (patch)
treeb9ec3e82661a645de400db72285949c93be66b12 /libq
parentbuildsys: regenerate (diff)
downloadportage-utils-8165933c5b9986b536cf91b8ba82f7e76c9cc758.tar.gz
portage-utils-8165933c5b9986b536cf91b8ba82f7e76c9cc758.tar.bz2
portage-utils-8165933c5b9986b536cf91b8ba82f7e76c9cc758.zip
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@gentoo.org>
Diffstat (limited to 'libq')
-rw-r--r--libq/move_file.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libq/move_file.c b/libq/move_file.c
index 07cf69fe..b98c8e2f 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;