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")
|
devcamDir := filepath.Join(camliSrcRoot, "dev", "devcam")
|
||||||
d, err := os.Open(devcamDir)
|
d, err := os.Open(devcamDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
return fmt.Errorf("could not read devcam source dir %v: %v", devcamDir, err)
|
||||||
}
|
}
|
||||||
defer d.Close()
|
defer d.Close()
|
||||||
fis, err := d.Readdir(-1)
|
fis, err := d.Readdir(-1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
return fmt.Errorf("could not read devcam source dir %v: %v", devcamDir, err)
|
||||||
}
|
}
|
||||||
for _, fi := range fis {
|
for _, fi := range fis {
|
||||||
if fi.ModTime().After(binModtime) {
|
if fi.ModTime().After(binModtime) {
|
||||||
|
@ -247,10 +247,13 @@ func build(path string) error {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cmdmain.CheckCwd = checkCamliSrcRoot
|
cmdmain.CheckCwd = checkCamliSrcRoot
|
||||||
|
cmdmain.CheckModtime = func() error {
|
||||||
if err := checkModtime(); err != nil {
|
if err := checkModtime(); err != nil {
|
||||||
log.Printf("Skipping freshness check: %v", err)
|
log.Printf("Skipping freshness check: %v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(mpl): usage error is not really correct for devcam.
|
// TODO(mpl): usage error is not really correct for devcam.
|
||||||
// See if I can reimplement it while still using cmdmain.Main().
|
// See if I can reimplement it while still using cmdmain.Main().
|
||||||
cmdmain.Main()
|
cmdmain.Main()
|
||||||
|
|
|
@ -51,6 +51,9 @@ var (
|
||||||
// CheckCwd checks the current working directory, and possibly
|
// CheckCwd checks the current working directory, and possibly
|
||||||
// changes it, or aborts the run if needed.
|
// changes it, or aborts the run if needed.
|
||||||
CheckCwd = func() {}
|
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")
|
var ErrUsage = UsageError("invalid command")
|
||||||
|
@ -238,6 +241,10 @@ func Main() {
|
||||||
}
|
}
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
CheckCwd()
|
CheckCwd()
|
||||||
|
if err := CheckModtime(); err != nil {
|
||||||
|
log.Print(err)
|
||||||
|
Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
args := flag.Args()
|
args := flag.Args()
|
||||||
if *FlagVersion {
|
if *FlagVersion {
|
||||||
|
|
Loading…
Reference in New Issue