A small application to manage Lilypond music repositories

Fill LastModified for Score types

+19 -1
+4 -1
compiler/compile.go
··· 52 52 switch filepath.Ext(path) { 53 53 case ".ly": 54 54 log.WithFields(log.Fields{"path": path}).Info("adding lilypond file") 55 - scores = append(scores, &settings.Score{Path: path}) 55 + scores = append(scores, &settings.Score{ 56 + Path: path, 57 + LastModified: file.LastModified, 58 + }) 56 59 57 60 case ".json": 58 61 if filepath.Base(path) != "ponder.json" {
+11
helpers/file_utils.go
··· 18 18 "errors" 19 19 "os" 20 20 "path/filepath" 21 + "time" 21 22 22 23 log "github.com/Sirupsen/logrus" 23 24 ) ··· 52 53 Panic("Unable to check path") 53 54 } 54 55 return false 56 + } 57 + 58 + // LastModified returns the time the file on the path was last modified, 59 + // if file lookup fails the current time is returned. 60 + func LastModified(path string) time.Time { 61 + stat, err := os.Stat(path) 62 + if err == nil { 63 + return stat.LastModified 64 + } 65 + return time.Now() 55 66 } 56 67 57 68 // FindFileDir returns the path of the
+4
settings/score.go
··· 18 18 "encoding/json" 19 19 "io/ioutil" 20 20 "time" 21 + 22 + "github.com/jjdekker/ponder/helpers" 21 23 ) 22 24 23 25 // Score represents the settings for a specific score file ··· 40 42 if err != nil { 41 43 return nil, err 42 44 } 45 + s.LastModified = helpers.LastModified(s.Path) 46 + 43 47 return &s, nil 44 48 }