mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01:00
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:
parent
54b9537a76
commit
b38a145cfd
@ -183,14 +183,12 @@ func (tbf *tmpBlocksFile) MustClose() {
|
|||||||
}
|
}
|
||||||
fname := tbf.f.Name()
|
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 {
|
if err := tbf.f.Close(); err != nil {
|
||||||
logger.Panicf("FATAL: cannot close %q: %s", fname, err)
|
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
|
tbf.f = nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user