From 0cef129db61fee25f1579c6df16b4dc15b4d7811 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Wed, 8 Feb 2023 21:48:19 +0300 Subject: [PATCH] add os stat to file validate method --- osutils/files.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/osutils/files.go b/osutils/files.go index cb87431..ffccca1 100644 --- a/osutils/files.go +++ b/osutils/files.go @@ -68,7 +68,7 @@ type FileValidationInfo struct { SHA1 string } -func ValidateFile(filePath string) (FileValidationInfo, error) { +func ValidateFile(filePath string) (*FileValidationInfo, error) { info := FileValidationInfo{ Path: filePath, FileInfo: nil, @@ -76,13 +76,19 @@ func ValidateFile(filePath string) (FileValidationInfo, error) { } info.Path = filePath + stat, err := os.Stat(filePath) + if err != nil { + return &info, err + } + info.FileInfo = stat + hash, err := GetFileHash(filePath) if err != nil { - return info, err + return &info, err } info.SHA1 = hash - return info, nil + return &info, nil } func GetFileHash(filePath string) (string, error) {