add os stat to file validate method
This commit is contained in:
parent
1a2732df7a
commit
0cef129db6
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user