mirror of https://github.com/perkeep/perkeep.git
devcam: add the -wipecache option
Change-Id: Ia3149361b3b210fd8e3b5fe42147018d3ab4e6fd
This commit is contained in:
parent
46efff80cc
commit
2fdb689503
|
@ -79,6 +79,11 @@ func (c *getCmd) RunCommand(args []string) error {
|
|||
}
|
||||
}
|
||||
c.env.SetCamdevVars(c.altkey)
|
||||
// wipeCacheDir needs to be called after SetCamdevVars, because that is
|
||||
// where CAMLI_CACHE_DIR is defined.
|
||||
if *wipeCache {
|
||||
c.env.wipeCacheDir()
|
||||
}
|
||||
|
||||
cmdBin := filepath.Join("bin", "camget")
|
||||
cmdArgs := []string{
|
||||
|
|
|
@ -92,6 +92,11 @@ func (c *mountCmd) RunCommand(args []string) error {
|
|||
}
|
||||
}
|
||||
c.env.SetCamdevVars(c.altkey)
|
||||
// wipeCacheDir needs to be called after SetCamdevVars, because that is
|
||||
// where CAMLI_CACHE_DIR is defined.
|
||||
if *wipeCache {
|
||||
c.env.wipeCacheDir()
|
||||
}
|
||||
|
||||
tryUnmount(mountpoint)
|
||||
if err := os.Mkdir(mountpoint, 0700); err != nil && !os.IsExist(err) {
|
||||
|
|
|
@ -77,6 +77,11 @@ func (c *putCmd) RunCommand(args []string) error {
|
|||
}
|
||||
}
|
||||
c.env.SetCamdevVars(c.altkey)
|
||||
// wipeCacheDir needs to be called after SetCamdevVars, because that is
|
||||
// where CAMLI_CACHE_DIR is defined.
|
||||
if *wipeCache {
|
||||
c.env.wipeCacheDir()
|
||||
}
|
||||
|
||||
blobserver := "http://localhost:" + c.port + c.path
|
||||
if c.tls {
|
||||
|
|
|
@ -66,6 +66,11 @@ func (c *toolCmd) RunCommand(args []string) error {
|
|||
}
|
||||
}
|
||||
c.env.SetCamdevVars(c.altkey)
|
||||
// wipeCacheDir needs to be called after SetCamdevVars, because that is
|
||||
// where CAMLI_CACHE_DIR is defined.
|
||||
if *wipeCache {
|
||||
c.env.wipeCacheDir()
|
||||
}
|
||||
|
||||
cmdBin := filepath.Join("bin", "camtool")
|
||||
return runExec(cmdBin, args, c.env)
|
||||
|
|
|
@ -36,9 +36,10 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
noBuild = flag.Bool("nobuild", false, "do not rebuild anything")
|
||||
race = flag.Bool("race", false, "build with race detector")
|
||||
quiet, _ = strconv.ParseBool(os.Getenv("CAMLI_QUIET"))
|
||||
noBuild = flag.Bool("nobuild", false, "do not rebuild anything")
|
||||
race = flag.Bool("race", false, "build with race detector")
|
||||
quiet, _ = strconv.ParseBool(os.Getenv("CAMLI_QUIET"))
|
||||
wipeCache = flag.Bool("wipecache", false, "wipe the cache directory. Server cache with devcam server, client cache otherwise.")
|
||||
// Whether to build the subcommand with sqlite support. This only
|
||||
// concerns the server subcommand, which sets it to serverCmd.sqlite.
|
||||
withSqlite bool
|
||||
|
@ -246,6 +247,7 @@ func build(path string) error {
|
|||
|
||||
func main() {
|
||||
cmdmain.CheckCwd = checkCamliSrcRoot
|
||||
|
||||
if err := checkModtime(); err != nil {
|
||||
log.Printf("Skipping freshness check: %v", err)
|
||||
}
|
||||
|
|
|
@ -153,3 +153,16 @@ func setCamdevVarsFor(e *Env, altkey bool) {
|
|||
setenv("CAMLI_PUBKEY_BLOBREF", pubKeyRef.String())
|
||||
setenv("CAMLI_KV_VERIFY", "true")
|
||||
}
|
||||
|
||||
func (e *Env) wipeCacheDir() {
|
||||
cacheDir, _ := e.m["CAMLI_CACHE_DIR"]
|
||||
if cacheDir == "" {
|
||||
log.Fatal("Could not wipe cache dir, CAMLI_CACHE_DIR not defined")
|
||||
}
|
||||
if err := os.RemoveAll(cacheDir); err != nil {
|
||||
log.Fatalf("Could not remove cache dir %v: %v", cacheDir, err)
|
||||
}
|
||||
if err := os.MkdirAll(cacheDir, 0700); err != nil {
|
||||
log.Fatalf("Could not recreate cache dir %v: %v", cacheDir, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -494,6 +494,11 @@ func (c *serverCmd) RunCommand(args []string) error {
|
|||
if err := c.setEnvVars(); err != nil {
|
||||
return fmt.Errorf("Could not setup the env vars: %v", err)
|
||||
}
|
||||
// wipeCacheDir needs to be called after setEnvVars, because that is where
|
||||
// CAMLI_CACHE_DIR is defined.
|
||||
if *wipeCache {
|
||||
c.env.wipeCacheDir()
|
||||
}
|
||||
if err := c.setupIndexer(); err != nil {
|
||||
return fmt.Errorf("Could not setup the indexer: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue