mirror of https://github.com/perkeep/perkeep.git
Merge "devcam: move modtime check after cwd check"
This commit is contained in:
commit
54d9ad1f0e
|
@ -191,12 +191,12 @@ func checkModtime() error {
|
|||
devcamDir := filepath.Join(camliSrcRoot, "dev", "devcam")
|
||||
d, err := os.Open(devcamDir)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return fmt.Errorf("could not read devcam source dir %v: %v", devcamDir, err)
|
||||
}
|
||||
defer d.Close()
|
||||
fis, err := d.Readdir(-1)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return fmt.Errorf("could not read devcam source dir %v: %v", devcamDir, err)
|
||||
}
|
||||
for _, fi := range fis {
|
||||
if fi.ModTime().After(binModtime) {
|
||||
|
@ -247,10 +247,13 @@ func build(path string) error {
|
|||
|
||||
func main() {
|
||||
cmdmain.CheckCwd = checkCamliSrcRoot
|
||||
|
||||
cmdmain.CheckModtime = func() error {
|
||||
if err := checkModtime(); err != nil {
|
||||
log.Printf("Skipping freshness check: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO(mpl): usage error is not really correct for devcam.
|
||||
// See if I can reimplement it while still using cmdmain.Main().
|
||||
cmdmain.Main()
|
||||
|
|
|
@ -51,6 +51,9 @@ var (
|
|||
// CheckCwd checks the current working directory, and possibly
|
||||
// changes it, or aborts the run if needed.
|
||||
CheckCwd = func() {}
|
||||
// CheckModtime provides a way to check if the currently running binary
|
||||
// is out of date. If it returns an error, the run is aborted.
|
||||
CheckModtime = func() error { return nil }
|
||||
)
|
||||
|
||||
var ErrUsage = UsageError("invalid command")
|
||||
|
@ -238,6 +241,10 @@ func Main() {
|
|||
}
|
||||
flag.Parse()
|
||||
CheckCwd()
|
||||
if err := CheckModtime(); err != nil {
|
||||
log.Print(err)
|
||||
Exit(1)
|
||||
}
|
||||
|
||||
args := flag.Args()
|
||||
if *FlagVersion {
|
||||
|
|
Loading…
Reference in New Issue