@@ -7,10 +7,8 @@ import (
77 "os"
88 "os/exec"
99 "path/filepath"
10- "reflect"
1110 "sort"
1211 "strings"
13- "syscall"
1412 "time"
1513
1614 "weightless/internal/providers"
@@ -59,7 +57,7 @@ type Artifact struct {
5957 CanonicalPath string `json:"canonical_path"`
6058 SizeBytes int64 `json:"size_bytes"`
6159 SizeHuman string `json:"size_human"`
62- CreatedAt string `json:"created_at ,omitempty"`
60+ Timestamp string `json:"timestamp ,omitempty"`
6361 FileCount int `json:"file_count,omitempty"`
6462 Matches []Match `json:"matches"`
6563 AllPaths []string `json:"all_paths"`
@@ -656,7 +654,7 @@ func buildAggregateArtifact(groupPath, modelName string, items []Artifact) Artif
656654 aggregate .OwnerReferences = collectOwners (items )
657655 aggregate .Notes = collectNotes (items )
658656 aggregate .Status = aggregateStatus (items )
659- aggregate .CreatedAt = aggregateCreatedAt (groupPath , items )
657+ aggregate .Timestamp = aggregateTimestamp (groupPath , items )
660658 aggregate .CanonicalMissing = false
661659 for _ , item := range items {
662660 aggregate .SizeBytes += item .SizeBytes
@@ -666,16 +664,16 @@ func buildAggregateArtifact(groupPath, modelName string, items []Artifact) Artif
666664 return aggregate
667665}
668666
669- func aggregateCreatedAt (groupPath string , items []Artifact ) string {
670- if createdAt := inferCreatedAt (groupPath ); createdAt != "" {
671- return createdAt
667+ func aggregateTimestamp (groupPath string , items []Artifact ) string {
668+ if timestamp := inferTimestamp (groupPath ); timestamp != "" {
669+ return timestamp
672670 }
673671 var earliest time.Time
674672 found := false
675673 for _ , item := range items {
676- current := item .CreatedAt
674+ current := item .Timestamp
677675 if current == "" {
678- current = inferCreatedAt (item .Path )
676+ current = inferTimestamp (item .Path )
679677 }
680678 if current == "" {
681679 continue
@@ -1055,7 +1053,7 @@ func finalizeArtifacts(artifacts []Artifact) {
10551053 artifacts [idx ].Status = inferStatus (artifacts [idx ])
10561054 artifacts [idx ].ModelName = displayModelName (inferModelName (artifacts [idx ]))
10571055 artifacts [idx ].Name = artifacts [idx ].ModelName
1058- artifacts [idx ].CreatedAt = inferCreatedAt (artifacts [idx ].Path )
1056+ artifacts [idx ].Timestamp = inferTimestamp (artifacts [idx ].Path )
10591057 if artifacts [idx ].Name == "" {
10601058 artifacts [idx ].Name = trimKnownExtensions (artifacts [idx ].FileName )
10611059 }
@@ -1332,58 +1330,26 @@ func trimKnownExtensions(name string) string {
13321330 return out
13331331}
13341332
1335- func inferCreatedAt (path string ) string {
1336- createdAt , ok := fileCreatedAt (path )
1333+ func inferTimestamp (path string ) string {
1334+ timestamp , ok := fileTimestamp (path )
13371335 if ! ok {
13381336 return ""
13391337 }
1340- return createdAt .Format (time .RFC3339 )
1338+ return timestamp .Format (time .RFC3339 )
13411339}
13421340
1343- func fileCreatedAt (path string ) (time.Time , bool ) {
1341+ func fileTimestamp (path string ) (time.Time , bool ) {
13441342 info , err := os .Stat (path )
13451343 if err != nil {
13461344 return time.Time {}, false
13471345 }
1348- if createdAt , ok := birthTimeFromFileInfo (info ); ok {
1349- return createdAt , true
1350- }
13511346 modifiedAt := info .ModTime ()
13521347 if modifiedAt .IsZero () {
13531348 return time.Time {}, false
13541349 }
13551350 return modifiedAt , true
13561351}
13571352
1358- func birthTimeFromFileInfo (info fs.FileInfo ) (time.Time , bool ) {
1359- sys , ok := info .Sys ().(* syscall.Stat_t )
1360- if ! ok || sys == nil {
1361- return time.Time {}, false
1362- }
1363- value := reflect .ValueOf (sys )
1364- if value .Kind () == reflect .Ptr {
1365- value = value .Elem ()
1366- }
1367- for _ , fieldName := range []string {"Birthtimespec" , "Birthtim" , "Btim" } {
1368- field := value .FieldByName (fieldName )
1369- if ! field .IsValid () {
1370- continue
1371- }
1372- secField := field .FieldByName ("Sec" )
1373- nsecField := field .FieldByName ("Nsec" )
1374- if ! secField .IsValid () || ! nsecField .IsValid () {
1375- continue
1376- }
1377- sec := secField .Int ()
1378- nsec := nsecField .Int ()
1379- if sec == 0 && nsec == 0 {
1380- continue
1381- }
1382- return time .Unix (sec , nsec ), true
1383- }
1384- return time.Time {}, false
1385- }
1386-
13871353func humanizeOwners (owners []string ) []string {
13881354 out := make ([]string , 0 , len (owners ))
13891355 for _ , owner := range owners {
0 commit comments