@@ -248,7 +248,7 @@ func (r *PhysRestore) close(noerr, cleanup bool) {
248
248
}
249
249
} else { // cluster status is done or partlyDone
250
250
r .log .Debug ("clean-up dbpath" )
251
- err := removeAll (r .dbpath , r .log )
251
+ err := removeAll (r .dbpath , nil , r .log )
252
252
if err != nil {
253
253
r .log .Error ("flush dbpath %s: %v" , r .dbpath , err )
254
254
}
@@ -392,7 +392,7 @@ func (r *PhysRestore) migrateDbDirToFallbackDir() error {
392
392
// moves all content from fallback path.
393
393
func (r * PhysRestore ) migrateFromFallbackDirToDbDir () error {
394
394
r .log .Debug ("clean-up dbpath" )
395
- err := removeAll (r .dbpath , r .log )
395
+ err := removeAll (r .dbpath , [] string { fallbackDir }, r .log )
396
396
if err != nil {
397
397
r .log .Error ("flush dbpath %s: %v" , r .dbpath , err )
398
398
}
@@ -2524,7 +2524,7 @@ func moveAll(fromDir, toDir string, toIgnore []string, l log.LogEvent) error {
2524
2524
return nil
2525
2525
}
2526
2526
2527
- func removeAll (dir string , l log.LogEvent ) error {
2527
+ func removeAll (dir string , toIgnore [] string , l log.LogEvent ) error {
2528
2528
d , err := os .Open (dir )
2529
2529
if err != nil {
2530
2530
return errors .Wrap (err , "open dir" )
@@ -2536,7 +2536,7 @@ func removeAll(dir string, l log.LogEvent) error {
2536
2536
return errors .Wrap (err , "read file names" )
2537
2537
}
2538
2538
for _ , n := range names {
2539
- if n == internalMongodLog || n == fallbackDir {
2539
+ if n == internalMongodLog || slices . Contains ( toIgnore , n ) {
2540
2540
continue
2541
2541
}
2542
2542
err = os .RemoveAll (filepath .Join (dir , n ))
0 commit comments