diff --git a/backend/core/file.go b/backend/core/file.go index 7cd52a8..e60998c 100644 --- a/backend/core/file.go +++ b/backend/core/file.go @@ -63,12 +63,14 @@ func getFileInfo(info fs.FileInfo, picd []PictureData, actualdir string) []Pictu func ListFiles(path string) []PictureData { var picd []PictureData picd = listFiles(path, "", picd) - println("") + start := time.Now() + print("\n") if len(picd) == 0 { util.Logformat(util.ERROR, "Could not gather any file.\n") return nil } else { - util.Logformat(util.CORRECT, "Gathered %d files.\n", len(picd)) + elapsed := time.Since(start) + util.Logformat(util.CORRECT, "Gathered %d files in %dms.\n", len(picd), elapsed.Milliseconds()) return picd } } diff --git a/backend/main.go b/backend/main.go index 71e36c1..690bdcd 100644 --- a/backend/main.go +++ b/backend/main.go @@ -4,18 +4,23 @@ import ( "backend/core" "backend/server" "backend/util" - "strings" + "errors" + "os" ) func main() { + // Set Log Level + util.SetLevel(util.NOLOG) + cfg, err := util.ReadConfig("config.json") if err != nil { - if strings.Compare(err.Error(), "open config.json: no such file or directory") == 0 { + if errors.Is(err, os.ErrNotExist) { util.Logformat(util.INFO, "Creating config file...\n") util.CreateConfig() - cfg, err = util.ReadConfig("config.json") + cfg, _ = util.ReadConfig("config.json") } else { util.Logformat(util.ERROR, "Could not read configuration file: %s\n", err.Error()) + panic(err) } } @@ -23,9 +28,6 @@ func main() { util.Logformat(util.INFO, "Reading folder '%s'\n", cfg.PhotoPath) core.ListFiles(cfg.PhotoPath) - // Set Log Level - util.SetLevel(util.NOLOG) - // Rest API start on port server.Start(8085) }