lib/model: Create root directory for paused folders (fixes #4094)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4095
This commit is contained in:
Simon Frei
2017-04-23 23:50:56 +00:00
committed by Jakob Borg
parent e9f05d138f
commit 914b09fd1f
3 changed files with 24 additions and 11 deletions

View File

@@ -231,18 +231,9 @@ func (m *Model) startFolderLocked(folder string) config.FolderType {
// Directory permission bits. Will be filtered down to something
// sane by umask on Unixes.
permBits := os.FileMode(0777)
if runtime.GOOS == "windows" {
// Windows has no umask so we must chose a safer set of bits to
// begin with.
permBits = 0700
}
if _, err := os.Stat(cfg.Path()); os.IsNotExist(err) {
if err := osutil.MkdirAll(cfg.Path(), permBits); err != nil {
l.Warnln("Creating folder:", err)
}
}
cfg.CreateRoot()
if err := cfg.CreateMarker(); err != nil {
l.Warnln("Creating folder marker:", err)
}
@@ -2385,6 +2376,7 @@ func (m *Model) CommitConfiguration(from, to config.Configuration) bool {
// A folder was added.
if cfg.Paused {
l.Infoln(m, "Paused folder", cfg.Description())
cfg.CreateRoot()
} else {
l.Infoln(m, "Adding folder", cfg.Description())
m.AddFolder(cfg)