Archived
1
0

Adds replacement strategy for PDF files when updated

This commit is contained in:
Jip J. Dekker 2016-04-17 12:22:49 +02:00
parent 573d863595
commit 57babbd052

View File

@ -48,8 +48,13 @@ func CompileDir(path string, opts *settings.Settings) {
case ".ly":
msg, err = Lilypond(scores[i].Path)
case ".pdf":
if helpers.Exists(scores[i].OutputPath) {
os.Remove(scores[i].OutputPath)
}
if err == nil {
err = os.Link(scores[i].Path, scores[i].OutputPath)
}
}
if err != nil {
log.WithFields(log.Fields{
@ -61,6 +66,7 @@ func CompileDir(path string, opts *settings.Settings) {
} else {
log.WithFields(log.Fields{
"score": scores[i],
"outputVersion": helpers.LastModified(scores[i].OutputPath),
}).Debug("skipping compilation")
}
}
@ -84,6 +90,7 @@ func generateScores() func(string, os.FileInfo) error {
if filepath.Base(path) != "ponder.json" {
log.WithFields(log.Fields{"path": path}).Info("adding json file")
score, err = settings.FromJSON(path)
score.LastModified = helpers.LastModified(score.Path)
}
default: