mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-18 14:47:03 +00:00
safeio: Prefix temporary files with "."
To avoid user and automation confusion, prefix the temporary files with a ".". That way, if something scans the directory for files, it's less likely to encounter one of our temporary files. This will become very relevant in subsequent patches.
This commit is contained in:
@@ -17,7 +17,9 @@ import (
|
|||||||
func WriteFile(filename string, data []byte, perm os.FileMode) error {
|
func WriteFile(filename string, data []byte, perm os.FileMode) error {
|
||||||
// Note we create the temporary file in the same directory, otherwise we
|
// Note we create the temporary file in the same directory, otherwise we
|
||||||
// would have no expectation of Rename being atomic.
|
// would have no expectation of Rename being atomic.
|
||||||
tmpf, err := ioutil.TempFile(path.Dir(filename), path.Base(filename))
|
// We make the file names start with "." so there's no confusion with the
|
||||||
|
// originals.
|
||||||
|
tmpf, err := ioutil.TempFile(path.Dir(filename), "."+path.Base(filename))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user