From b3a2a76f25becb09a16d38c3df0111333311a0b3 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Mon, 24 Aug 2020 11:29:40 -0600 Subject: [PATCH 1/3] Fix log directory not being created --- cmd/root.go | 4 ++++ config/config_system.go | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 101a8ce..1fcd9fa 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -337,6 +337,10 @@ func Execute() error { // Configures the global logger for Zap so that we can call it from any location // in the code without having to pass around a logger instance. func configureLogging(logDir string, debug bool) error { + if err := os.MkdirAll(config.Get().System.LogDirectory, 0700); err != nil { + return errors.WithStack(err) + } + cfg := zap.NewProductionConfig() if debug { cfg = zap.NewDevelopmentConfig() diff --git a/config/config_system.go b/config/config_system.go index 3fec067..f946e6c 100644 --- a/config/config_system.go +++ b/config/config_system.go @@ -49,11 +49,6 @@ func (sc *SystemConfiguration) ConfigureDirectories() error { return err } - log.WithField("path", sc.LogDirectory).Debug("ensuring log directory exists") - if err := os.MkdirAll(path.Join(sc.LogDirectory, "/install"), 0700); err != nil { - return err - } - log.WithField("path", sc.Data).Debug("ensuring server data directory exists") if err := os.MkdirAll(sc.Data, 0700); err != nil { return err From 459c3702294d8bc0a2510df7ad1ae04d2ab218f0 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Mon, 24 Aug 2020 15:10:57 -0600 Subject: [PATCH 2/3] Create install directory when creating the logs directory --- cmd/root.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index 1fcd9fa..ea40768 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -337,7 +337,7 @@ func Execute() error { // Configures the global logger for Zap so that we can call it from any location // in the code without having to pass around a logger instance. func configureLogging(logDir string, debug bool) error { - if err := os.MkdirAll(config.Get().System.LogDirectory, 0700); err != nil { + if err := os.MkdirAll(path.Join(config.Get().System.LogDirectory, "/install"), 0700); err != nil { return errors.WithStack(err) } From 9f27119044b74b9200d39540ee60fb6935d61ac6 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Mon, 24 Aug 2020 20:22:19 -0600 Subject: [PATCH 3/3] Fix log directory not being created, again.. --- cmd/root.go | 2 +- server/filesystem.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index ea40768..da9f4f9 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -337,7 +337,7 @@ func Execute() error { // Configures the global logger for Zap so that we can call it from any location // in the code without having to pass around a logger instance. func configureLogging(logDir string, debug bool) error { - if err := os.MkdirAll(path.Join(config.Get().System.LogDirectory, "/install"), 0700); err != nil { + if err := os.MkdirAll(path.Join(logDir, "/install"), 0700); err != nil { return errors.WithStack(err) } diff --git a/server/filesystem.go b/server/filesystem.go index e088aaf..0cb6803 100644 --- a/server/filesystem.go +++ b/server/filesystem.go @@ -574,7 +574,8 @@ func (fs *Filesystem) Copy(p string) error { } defer dest.Close() - if _, err := io.Copy(dest, source); err != nil { + buf := make([]byte, 1024*4) + if _, err := io.CopyBuffer(dest, source, buf); err != nil { return errors.WithStack(err) }