Fill LastModified for Score types
This commit is contained in:
parent
fe24e38627
commit
f286816b98
@ -52,7 +52,10 @@ func generateScores() func(string, os.FileInfo) error {
|
||||
switch filepath.Ext(path) {
|
||||
case ".ly":
|
||||
log.WithFields(log.Fields{"path": path}).Info("adding lilypond file")
|
||||
scores = append(scores, &settings.Score{Path: path})
|
||||
scores = append(scores, &settings.Score{
|
||||
Path: path,
|
||||
LastModified: file.LastModified,
|
||||
})
|
||||
|
||||
case ".json":
|
||||
if filepath.Base(path) != "ponder.json" {
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
)
|
||||
@ -54,6 +55,16 @@ func Exists(path string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// LastModified returns the time the file on the path was last modified,
|
||||
// if file lookup fails the current time is returned.
|
||||
func LastModified(path string) time.Time {
|
||||
stat, err := os.Stat(path)
|
||||
if err == nil {
|
||||
return stat.LastModified
|
||||
}
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
// FindFileDir returns the path of the
|
||||
func FindFileDir(file string) (string, error) {
|
||||
wd, err := os.Getwd()
|
||||
|
@ -18,6 +18,8 @@ import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"time"
|
||||
|
||||
"github.com/jjdekker/ponder/helpers"
|
||||
)
|
||||
|
||||
// Score represents the settings for a specific score file
|
||||
@ -40,5 +42,7 @@ func FromJSON(path string) (*Score, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.LastModified = helpers.LastModified(s.Path)
|
||||
|
||||
return &s, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user