mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Merge pull request #1754 from prometheus/jan11011977-master
Fix 'access denied' error on Windows
This commit is contained in:
commit
f928ca13d0
|
@ -812,6 +812,9 @@ func (p *persistence) dropAndPersistChunks(
|
||||||
}
|
}
|
||||||
_, err = io.ReadFull(f, headerBuf)
|
_, err = io.ReadFull(f, headerBuf)
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
// Close the file before trying to delete it. This is necessary on Windows
|
||||||
|
// (this will cause the defer f.Close to fail, but the error is silently ignored)
|
||||||
|
f.Close()
|
||||||
// We ran into the end of the file without finding any chunks that should
|
// We ran into the end of the file without finding any chunks that should
|
||||||
// be kept. Remove the whole file.
|
// be kept. Remove the whole file.
|
||||||
if numDropped, err = p.deleteSeriesFile(fp); err != nil {
|
if numDropped, err = p.deleteSeriesFile(fp); err != nil {
|
||||||
|
@ -875,6 +878,9 @@ func (p *persistence) dropAndPersistChunks(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
|
// Close the file before trying to rename to it. This is necessary on Windows
|
||||||
|
// (this will cause the defer f.Close to fail, but the error is silently ignored)
|
||||||
|
f.Close()
|
||||||
p.closeChunkFile(temp)
|
p.closeChunkFile(temp)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = os.Rename(p.tempFileNameForFingerprint(fp), p.fileNameForFingerprint(fp))
|
err = os.Rename(p.tempFileNameForFingerprint(fp), p.fileNameForFingerprint(fp))
|
||||||
|
|
Loading…
Reference in a new issue