Skip to content

Commit

Permalink
[preprocessor/folder] add project based file attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed May 27, 2024
1 parent 91ae53e commit c49683f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions preprocessor/folder/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os"
"path/filepath"
"slices"
"strings"

"github.com/jackc/pgx/v5/pgxpool"
"github.com/starlinglab/integrity-v2/config"
Expand Down Expand Up @@ -49,6 +50,8 @@ func getFileMetadata(filePath string) (map[string]any, error) {
}
mediaType := http.DetectContentType(bytes)

syncRoot := config.GetConfig().FolderPreprocessor.SyncFolderRoot

return map[string]any{
"sha256": hex.EncodeToString(sha.Sum(nil)),
"md5": hex.EncodeToString(md.Sum(nil)),
Expand All @@ -57,6 +60,7 @@ func getFileMetadata(filePath string) (map[string]any, error) {
"file_size": fileInfo.Size(),
"file_name": fileInfo.Name(),
"last_modified": fileInfo.ModTime(),
"asset_origin": strings.TrimPrefix(filePath, syncRoot),
}, nil
}

Expand Down

0 comments on commit c49683f

Please sign in to comment.