From fc9442b6a3a3c521756e7350488e13c06c41daa6 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Tue, 21 Jul 2020 15:01:46 +0200 Subject: [PATCH] Index: Don't expose full directory names in logs #391 Signed-off-by: Michael Mayer --- internal/photoprism/convert.go | 3 ++- internal/photoprism/import.go | 3 ++- internal/photoprism/index.go | 3 ++- internal/photoprism/resample.go | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/photoprism/convert.go b/internal/photoprism/convert.go index 53e8af87e..71ac5fc7c 100644 --- a/internal/photoprism/convert.go +++ b/internal/photoprism/convert.go @@ -10,6 +10,7 @@ import ( "path/filepath" "runtime/debug" "strconv" + "strings" "sync" "github.com/karrick/godirwalk" @@ -66,7 +67,7 @@ func (c *Convert) Start(path string) error { err := godirwalk.Walk(path, &godirwalk.Options{ ErrorCallback: func(fileName string, err error) godirwalk.ErrorAction { - log.Errorf("convert: %s", err) + log.Errorf("convert: %s", strings.Replace(err.Error(), path, "", 1)) return godirwalk.SkipNode }, Callback: func(fileName string, info *godirwalk.Dirent) error { diff --git a/internal/photoprism/import.go b/internal/photoprism/import.go index ca8e11e1f..5df7eb895 100644 --- a/internal/photoprism/import.go +++ b/internal/photoprism/import.go @@ -8,6 +8,7 @@ import ( "runtime" "runtime/debug" "sort" + "strings" "sync" "github.com/karrick/godirwalk" @@ -98,7 +99,7 @@ func (imp *Import) Start(opt ImportOptions) fs.Done { err := godirwalk.Walk(importPath, &godirwalk.Options{ ErrorCallback: func(fileName string, err error) godirwalk.ErrorAction { - log.Errorf("import: %s", err) + log.Errorf("import: %s", strings.Replace(err.Error(), importPath, "", 1)) return godirwalk.SkipNode }, Callback: func(fileName string, info *godirwalk.Dirent) error { diff --git a/internal/photoprism/index.go b/internal/photoprism/index.go index 50caa2f8a..c01b908a6 100644 --- a/internal/photoprism/index.go +++ b/internal/photoprism/index.go @@ -6,6 +6,7 @@ import ( "path/filepath" "runtime" "runtime/debug" + "strings" "sync" "github.com/karrick/godirwalk" @@ -114,7 +115,7 @@ func (ind *Index) Start(opt IndexOptions) fs.Done { err := godirwalk.Walk(optionsPath, &godirwalk.Options{ ErrorCallback: func(fileName string, err error) godirwalk.ErrorAction { - log.Errorf("index: %s", err) + log.Errorf("index: %s", strings.Replace(err.Error(), originalsPath, "", 1)) return godirwalk.SkipNode }, Callback: func(fileName string, info *godirwalk.Dirent) error { diff --git a/internal/photoprism/resample.go b/internal/photoprism/resample.go index 536702ab4..542b1adfa 100644 --- a/internal/photoprism/resample.go +++ b/internal/photoprism/resample.go @@ -5,6 +5,7 @@ import ( "fmt" "path/filepath" "runtime/debug" + "strings" "sync" "github.com/karrick/godirwalk" @@ -68,7 +69,7 @@ func (rs *Resample) Start(force bool) (err error) { err = godirwalk.Walk(originalsPath, &godirwalk.Options{ ErrorCallback: func(fileName string, err error) godirwalk.ErrorAction { - log.Errorf("resample: %s", err) + log.Errorf("resample: %s", strings.Replace(err.Error(), originalsPath, "", 1)) return godirwalk.SkipNode }, Callback: func(fileName string, info *godirwalk.Dirent) error {