NX-Shell icon indicating copy to clipboard operation
NX-Shell copied to clipboard

Infinite Recursive Folder Copy

Open fivezeroes opened this issue 7 years ago • 6 comments

If you attempt to copy some folder A into itself, the result will run infinitely and soft-lock the system. Not sure of the appropriate fix, perhaps a temporary directory to copy files to, and then move them to the final directory, or add an exception to ignore itself when copying. ¯\(ツ)

fivezeroes avatar Jul 19 '18 02:07 fivezeroes

That would increase wear on the sdcard sadly. It would have to be done on a case by case process. Check weather your copying a file into its subdir each time you copy a file and complain to the user if they are trying to copy a file onto itself.

fennectech avatar Jul 19 '18 02:07 fennectech

The ignore itself thing might still be viable I'd imagine, I haven't really done much for file handling outside of copy and paste C++ and Python methods, but if there's a way to look at the destination folder like a pointer then just pass that as something to ignore from for the copy function.

fivezeroes avatar Jul 19 '18 02:07 fivezeroes

Yeah I'll just check if the destination path is the same as source path and if it is make it do nothing. No point in copying the same folder unless it has something different. Perhaps I should add a confirmation dialog for overwriting files. I'll take a look when I get time.

joel16 avatar Jul 19 '18 04:07 joel16

Also check that the folder your copying to isnt inside the folder your copying. So. Dont copy /switch/edizon to /switch/edizon/files/ as that can get. Problematic.

fennectech avatar Jul 19 '18 04:07 fennectech

Oops commented with my alt account. Another thing that came to mind with the overwrite prompt, would it be relatively easy to offer rename on paste? What originally brought this about was me wanting to copy a folder but hoping it would add something like " - copy" to the end of the name, but instead having to copy it to a temporary directory, rename it, and then move it next to the original folder.

fivezeroes avatar Jul 19 '18 04:07 fivezeroes

Solution is very easy - just create list of files to copy before copy and do not use recursion.

ghost avatar Aug 30 '22 09:08 ghost