Skip to content

Commit

Permalink
fix issue where files could be overwritten when --fix-conflicts is used
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoisaiah committed Jul 19, 2023
1 parent 70a2b95 commit cae92a4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions f2_test/f2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ var fileSystem = []string{
"ebooks/green-mile_1996.mobi",
"ebooks/.banned/.mein-kampf.pdf",
"ebooks/.banned/lolita.epub",
"text/test.TXT",
"text/test_A.txt",
"text/test-1.txt",
"text/test_A-1.txt",
".golang.pdf",
}

Expand Down
11 changes: 11 additions & 0 deletions testdata/all.json
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,17 @@
"args": "-f 001 -r 002 -F",
"path_args": ["images"]
},
{
"name": "auto fix multiple overwriting new path conflict",
"want": [
"test-1.txt|test1-1.txt|text",
"test.TXT|test1.txt|text",
"test_A.txt|test1 (2).txt|text",
"test_A-1.txt|test1-1 (2).txt|text"
],
"args": "-f '.*?(\\-1)?\\.(txt|TXT)' -r 'test1${1}.txt' -F",
"path_args": ["text"]
},
{
"name": "auto fix overwriting new path conflict",
"want": [
Expand Down
3 changes: 2 additions & 1 deletion validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ func checkOverwritingPathConflict(
for targetPath, source := range renamedPaths {
if len(source) > 1 {
var sources []string

for _, s := range source {
sources = append(sources, s.sourcePath)
changes[s.index].Status = status.OverwritingNewPath
Expand Down Expand Up @@ -246,7 +247,7 @@ func checkOverwritingPathConflict(
}
}

return
continue
}

conflicts[conflict.OverwritingNewPath] = append(
Expand Down

0 comments on commit cae92a4

Please sign in to comment.