mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-25 16:08:25 +00:00
Use temp file in same location as final .stignore
This commit is contained in:
parent
55c7d86205
commit
7fd2e4d2db
@ -10,7 +10,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -617,11 +617,13 @@ func (m *Model) SetIgnores(repo string, content []string) error {
|
|||||||
return fmt.Errorf("Repo %s does not exist", repo)
|
return fmt.Errorf("Repo %s does not exist", repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
fd, err := ioutil.TempFile("", "stignore-"+repo)
|
tmpFileName := filepath.Join(cfg.Directory, fmt.Sprintf(".stignore.%d", rand.Int63()))
|
||||||
|
fd, err := os.Create(tmpFileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Warnln("Saving .stignore:", err)
|
l.Warnln("Saving .stignore:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer os.Remove(tmpFileName)
|
||||||
|
|
||||||
writer := bufio.NewWriter(fd)
|
writer := bufio.NewWriter(fd)
|
||||||
for _, line := range content {
|
for _, line := range content {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user