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 30, 2024
1 parent 01f3a29 commit 49e9f94
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"
"time"

"github.com/jackc/pgx/v5/pgxpool"
Expand Down Expand Up @@ -53,6 +54,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 @@ -62,6 +65,7 @@ func getFileMetadata(filePath string) (map[string]any, error) {
"file_name": fileInfo.Name(),
"last_modified": fileInfo.ModTime().Format(time.RFC3339),
"time_created": fileInfo.ModTime().Format(time.RFC3339),
"asset_origin": strings.TrimPrefix(filePath, syncRoot),
}, nil
}

Expand Down

0 comments on commit 49e9f94

Please sign in to comment.