]> Sergey Matveev's repositories - nnn.git/commitdiff
Ensure co file does not have stale paths
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 10 Nov 2018 23:16:59 +0000 (04:46 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 10 Nov 2018 23:30:37 +0000 (05:00 +0530)
src/nnn.c

index ba8cef65c3bf166236a484c570300321586b566d..75044b68b5f66d5b45847c69f1fbf1d6ae5c5bd9 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2967,6 +2967,20 @@ nochange:
                                goto nochange;
 
                        if (cfg.copymode) {
+                               /*
+                                * Clear the tmp copy path file on first copy.
+                                *
+                                * This ensures that when the first file path is
+                                * copied into memory (but not written to tmp file
+                                * yet to save on writes), the tmp file is cleared.
+                                * The user may be in the middle of a multicopy op
+                                * and issue a cp, mv of multi-rm assuming the files
+                                * in the copy list would be affected. However, these
+                                * ops read the source file paths from the tmp file.
+                                */
+                               if (!ncp)
+                                       writecp(NULL, 0);
+
                                r = mkpath(path, dents[cur].name, newpath, PATH_MAX);
                                if (!appendfpath(newpath, r))
                                        goto nochange;