2014-11-16 13:13:20 -07:00
|
|
|
// Copyright (C) 2014 The Syncthing Authors.
|
2014-09-29 12:43:32 -07:00
|
|
|
//
|
2015-03-07 13:36:35 -07:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
2014-07-31 03:30:19 -07:00
|
|
|
|
2014-07-06 05:46:48 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"os"
|
2015-10-23 12:02:38 -07:00
|
|
|
"path/filepath"
|
2014-07-06 05:46:48 -07:00
|
|
|
|
2016-07-04 03:40:29 -07:00
|
|
|
"github.com/syncthing/syncthing/lib/db"
|
2014-07-06 05:46:48 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2015-10-23 12:02:38 -07:00
|
|
|
var mode string
|
2014-07-06 05:46:48 -07:00
|
|
|
log.SetFlags(0)
|
|
|
|
log.SetOutput(os.Stdout)
|
|
|
|
|
2015-10-23 12:02:38 -07:00
|
|
|
flag.StringVar(&mode, "mode", "dump", "Mode of operation: dump, dumpsize")
|
|
|
|
|
2014-07-06 05:46:48 -07:00
|
|
|
flag.Parse()
|
|
|
|
|
2015-10-23 12:02:38 -07:00
|
|
|
path := flag.Arg(0)
|
|
|
|
if path == "" {
|
2016-07-04 03:40:29 -07:00
|
|
|
path = filepath.Join(defaultConfigDir(), "index-v0.14.0.db")
|
2015-10-23 12:02:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("Path:", path)
|
|
|
|
|
2016-07-04 03:40:29 -07:00
|
|
|
ldb, err := db.Open(path)
|
2014-07-06 05:46:48 -07:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2015-10-23 12:02:38 -07:00
|
|
|
if mode == "dump" {
|
|
|
|
dump(ldb)
|
|
|
|
} else if mode == "dumpsize" {
|
2015-10-23 12:21:21 -07:00
|
|
|
dumpsize(ldb)
|
2015-10-23 12:02:38 -07:00
|
|
|
} else {
|
|
|
|
fmt.Println("Unknown mode")
|
2014-07-06 05:46:48 -07:00
|
|
|
}
|
|
|
|
}
|