File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ func (fm *FileManager) ValidateDestDir() error {
1515 dstInfo , err := os .Stat (fm .DestDir )
1616 if err != nil {
1717 if os .IsNotExist (err ) {
18- return os .MkdirAll (fm .DestDir , 0755 )
18+ // if destination does not exist, skip validation since the given
19+ // destination will be created in `fm.MoveFiles`. if created here,
20+ // `os.Rename` operation will fail due to an existing newpath
21+ return nil
1922 }
2023 return err
2124 }
@@ -40,7 +43,11 @@ func (fm *FileManager) MoveFiles(sources []string, tempDir string) error {
4043 dst := filepath .Join (fm .DestDir , ford )
4144 if err := os .Rename (src , dst ); err != nil {
4245 if errors .Is (err , os .ErrExist ) {
43- // overwrite (delete) existing directory here
46+ // if options.Force:
47+ // — delete existing directory dst
48+ // - return nil to continue with overwrite
49+ // else:
50+ return fmt .Errorf ("directory with content at `%s' would be overwritten, skipping…" , dst )
4451 }
4552 return err
4653 }
You can’t perform that action at this time.
0 commit comments