mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-22 01:07:27 +02:00
Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.
18 lines
447 B
Go
18 lines
447 B
Go
//go:build !windows
|
|||
|
|||
package cache
|
|||
|
|||
import (
|
|||
"os"
|
|||
|
|||
"github.com/djherbis/stream"
|
|||
)
|
|||
|
|||
// createDataFile unlinks instead of truncating, so a re-created entry gets a fresh
|
|||
// inode and readers still holding the old one see its full contents.
|
|||
func createDataFile(name string) (stream.File, error) {
|
|||
if err := os.Remove(name); err != nil && !os.IsNotExist(err) {
|
|||
return nil, err
|
|||
}
|
|||
return os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
|
|||
}
|