delete: Use physical Dir() for proper prefix cleanup in Windows (#9297)

In FS mode under Windows, removing an object will not automatically.
remove parent empty prefixes.

The reason is that path.Dir() was used, however filepath.Dir() is
more appropriate since filepath is physical (meaning it operates
on OS filesystem paths)

This is not caught because failure for Windows CI is not caught.
This commit is contained in:
Anis Elleuch 2020-04-08 19:32:58 +01:00 committed by GitHub
parent 2bbc6a83e8
commit e51e465543
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 4 deletions

View File

@ -1452,10 +1452,7 @@ func deleteFile(basePath, deletePath string, recursive bool) error {
}
}
// Trailing slash is removed when found to ensure
// slashpath.Dir() to work as intended.
deletePath = strings.TrimSuffix(deletePath, SlashSeparator)
deletePath = slashpath.Dir(deletePath)
deletePath = filepath.Dir(deletePath)
// Delete parent directory obviously not recursively. Errors for
// parent directories shouldn't trickle down.