From 64b5a1b738d38fc7c232a03daeca4f20dbd8dc8d Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sun, 25 May 2025 08:10:17 +0200 Subject: [PATCH] fix(syncthing): ensure both config and data dirs exist at startup (fixes #10126) (#10127) Previously we'd only ensure the config dir, which is often but not always the same as the data dir. Fixes #10126 --- cmd/syncthing/main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 49e3bbc8f..6a1185d98 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -349,10 +349,12 @@ func (options serveOptions) Run() error { return nil } - // Ensure that our home directory exists. - if err := syncthing.EnsureDir(locations.GetBaseDir(locations.ConfigBaseDir), 0o700); err != nil { - l.Warnln("Failure on home directory:", err) - os.Exit(svcutil.ExitError.AsInt()) + // Ensure that our config and data directories exist. + for _, loc := range []locations.BaseDirEnum{locations.ConfigBaseDir, locations.DataBaseDir} { + if err := syncthing.EnsureDir(locations.GetBaseDir(loc), 0o700); err != nil { + l.Warnln("Failed to ensure directory exists:", err) + os.Exit(svcutil.ExitError.AsInt()) + } } if options.UpgradeTo != "" {