Skip to content

Commit 2f1db8e

Browse files
author
Matt Allen
committed
When attempting to move the file, the complete destination folder hierarchy is now also created
1 parent ecaac2f commit 2f1db8e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

folders.go

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func substring(s string, i int) string {
3838

3939
// Move a file from one location to another
4040
func moveFile(s, d string) error {
41+
// Need to make sure the full hierarchy of the destination exists
42+
_ = os.MkdirAll(d, 0755)
4143
// Firstly, try renaming it. This will fail if the files are on different partitions.
4244
err := os.Rename(s, d)
4345
// If that fails then we need to make a copy of the file, then delete the existing one.

0 commit comments

Comments
 (0)