Check verifies that the file is good and hasn't changed
()
| 118 | |
| 119 | // Check verifies that the file is good and hasn't changed |
| 120 | func (times *FileTime) Check() (err error) { |
| 121 | stat, err := getLatestStat(times.Path) |
| 122 | |
| 123 | switch { |
| 124 | case os.IsNotExist(err): |
| 125 | if times.Exists { |
| 126 | logDebug("Stat Check: %s: gone", times.Path) |
| 127 | return checkFailed{fmt.Sprintf("File %q is missing (Stat)", times.Path)} |
| 128 | } |
| 129 | case err != nil: |
| 130 | logDebug("Stat Check: %s: ERR: %v", times.Path, err) |
| 131 | return err |
| 132 | case !times.Exists: |
| 133 | logDebug("Check: %s: appeared", times.Path) |
| 134 | return checkFailed{fmt.Sprintf("File %q newly created", times.Path)} |
| 135 | case stat.ModTime().Unix() != times.Modtime: |
| 136 | logDebug("Check: %s: stale (stat: %v, lastcheck: %v)", |
| 137 | times.Path, stat.ModTime().Unix(), times.Modtime) |
| 138 | return checkFailed{fmt.Sprintf("File %q has changed", times.Path)} |
| 139 | } |
| 140 | logDebug("Check: %s: up to date", times.Path) |
| 141 | return nil |
| 142 | } |
| 143 | |
| 144 | // Formatted shows the times in a user-friendly format. |
| 145 | func (times *FileTime) Formatted(relDir string) string { |
no test coverage detected