From 533433f163298c39695dcf6f23d64b83968061df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Gul=C3=A1csi?= Date: Sat, 18 Jul 2015 21:44:26 +0200 Subject: [PATCH] cmd/camtool reindex-diskpacked: don't panic on high-level conf If no metaIndex is specified, just go on, but don't panic. Also try to clear the logic a little bit (don't overwrite indexConf). Change-Id: I43e61ac3d5cd239cc113cb034ff3dd61eaaa14fd --- cmd/camtool/dp_idx_rebuild.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/camtool/dp_idx_rebuild.go b/cmd/camtool/dp_idx_rebuild.go index 7406dd2fb..45edbf5b8 100644 --- a/cmd/camtool/dp_idx_rebuild.go +++ b/cmd/camtool/dp_idx_rebuild.go @@ -73,7 +73,7 @@ func (c *reindexdpCmd) RunCommand(args []string) error { if !ok { return fmt.Errorf("No 'prefixes' object in low-level (or converted) config file %s", osutil.UserServerConfigPath()) } - paths := []string{} + paths, confs := []string{}, []jsonconfig.Obj{} for prefix, vei := range prefixes { pmap, ok := vei.(map[string]interface{}) if !ok { @@ -103,8 +103,7 @@ func (c *reindexdpCmd) RunCommand(args []string) error { continue } paths = append(paths, apath) - indexConf = jsonconfig.Obj(aconf["metaIndex"].(map[string]interface{})) - log.Printf("indexConf: %v", indexConf) + confs = append(confs, aconf) } if len(paths) == 0 { return fmt.Errorf("Server config file %s doesn't specify a disk-packed storage handler.", @@ -117,6 +116,13 @@ func (c *reindexdpCmd) RunCommand(args []string) error { if path == "" { return errors.New("no path is given/found") } + // If no index is specified, the default will be used (as on the regular path). + if mi := confs[0]["metaIndex"]; mi != nil { + if mi, ok := mi.(map[string]interface{}); ok { + indexConf = jsonconfig.Obj(mi) + } + } + log.Printf("indexConf: %v", indexConf) return diskpacked.Reindex(path, c.overwrite, indexConf) }