mirror of
https://github.com/gravitational/teleport.git
synced 2026-09-24 16:17:11 +08:00
removeSecure() should close the file before removing it on Windows (#32948)
* `removeSecure()` should close the file before removing it on Windows * Do not return early if `Close()` returns an error
This commit is contained in:
+4
-1
@@ -323,7 +323,10 @@ func removeSecure(filePath string, fi os.FileInfo) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
return trace.ConvertSystemError(os.Remove(filePath))
|
||||
// The file should be closed before removing it on Windows.
|
||||
closeErr := trace.ConvertSystemError(f.Close())
|
||||
removeErr := trace.ConvertSystemError(os.Remove(filePath))
|
||||
return trace.NewAggregate(closeErr, removeErr)
|
||||
} else {
|
||||
removeErr := os.Remove(filePath)
|
||||
if f != nil {
|
||||
|
||||
Reference in New Issue
Block a user