1
0
mirror of https://github.com/go-task/task.git synced 2025-11-06 09:09:13 +02:00

Don't persist new checksum on the disk if dry mode is enabled

Fixes #166
This commit is contained in:
Andrey Nering
2019-02-09 10:41:19 -02:00
parent 713ecd35f6
commit 902f0d3ac4
7 changed files with 57 additions and 14 deletions

View File

@@ -17,6 +17,7 @@ type Checksum struct {
Dir string
Task string
Sources []string
Dry bool
}
// IsUpToDate implements the Checker interface
@@ -36,9 +37,11 @@ func (c *Checksum) IsUpToDate() (bool, error) {
return false, nil
}
_ = os.MkdirAll(filepath.Join(c.Dir, ".task", "checksum"), 0755)
if err = ioutil.WriteFile(checksumFile, []byte(newMd5+"\n"), 0644); err != nil {
return false, err
if !c.Dry {
_ = os.MkdirAll(filepath.Join(c.Dir, ".task", "checksum"), 0755)
if err = ioutil.WriteFile(checksumFile, []byte(newMd5+"\n"), 0644); err != nil {
return false, err
}
}
return oldMd5 == newMd5, nil
}