Fix bug in fsBackend and add tests for file utils

This commit is contained in:
2023-06-28 07:39:39 +02:00
parent ab1a9fa781
commit 6d8a3aa256
5 changed files with 77 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
// Copyright (C) 2023 NHR@FAU, University Erlangen-Nuremberg.
// All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
@@ -20,6 +20,7 @@ func GetFilesize(filePath string) int64 {
fileInfo, err := os.Stat(filePath)
if err != nil {
log.Errorf("Error on Stat %s: %v", filePath, err)
return 0
}
return fileInfo.Size()
}
@@ -28,6 +29,7 @@ func GetFilecount(path string) int {
files, err := os.ReadDir(path)
if err != nil {
log.Errorf("Error on ReadDir %s: %v", path, err)
return 0
}
return len(files)