app/vmselect: properly remove temp files at windows system (#4020)

With non-posix compliant systems it's not possible to remove unclosed files.

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/70
This commit is contained in:
Nikolay 2023-03-28 03:10:15 +02:00 committed by GitHub
parent 02ee4ffd4d
commit 9b1e002287
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -179,14 +179,12 @@ func (tbf *tmpBlocksFile) MustClose() {
}
fname := tbf.f.Name()
// Remove the file at first, then close it.
// This way the OS shouldn't try to flush file contents to storage
// on close.
if err := os.Remove(fname); err != nil {
logger.Panicf("FATAL: cannot remove %q: %s", fname, err)
}
if err := tbf.f.Close(); err != nil {
logger.Panicf("FATAL: cannot close %q: %s", fname, err)
}
// We cannot remove unclosed at non-posix filesystems, like windows
if err := os.Remove(fname); err != nil {
logger.Panicf("FATAL: cannot remove %q: %s", fname, err)
}
tbf.f = nil
}