From 1449729882f146fdf454bcfeb88d42f8f4c7362b Mon Sep 17 00:00:00 2001 From: Christian Schmied Date: Fri, 27 Sep 2024 16:59:38 +0200 Subject: [PATCH 1/2] first write Error file then Move File, so the move error can also be detected while the error writing is always done first --- FileArchiver.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FileArchiver.go b/FileArchiver.go index 92da89d..ad68bc5 100644 --- a/FileArchiver.go +++ b/FileArchiver.go @@ -94,10 +94,13 @@ func moveToError(conf *Config, filePath string, archiveErr error) error { if err != nil { return err } - err = os.Rename(filePath, filepath.Join(destFolder, baseName)) err = writeErrorFile(conf, filePath, archiveErr) if err != nil { return err } + err = os.Rename(filePath, filepath.Join(destFolder, baseName)) + if err != nil { + return err + } return nil } From 76c2a7be5e5b2d6b1a4a2932707cf0de5f7cef4b Mon Sep 17 00:00:00 2001 From: Christian Schmied Date: Sat, 26 Oct 2024 19:13:32 +0200 Subject: [PATCH 2/2] fix ErrorOnlyArchiver logging Error, also when there is none --- ErrorOnlyArchiver.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ErrorOnlyArchiver.go b/ErrorOnlyArchiver.go index 20df8b1..f17bc7b 100644 --- a/ErrorOnlyArchiver.go +++ b/ErrorOnlyArchiver.go @@ -9,7 +9,9 @@ func NewErrorOnlyArchiver(conf *Config) func(string, error) { return func(filePath string, archiveErr error) { if archiveErr != nil { err := writeErrorFile(conf, filePath, archiveErr) - logger.Error(err) + if err != nil { + logger.Error(err) + } } } }