main.go 856 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at http://mozilla.org/MPL/2.0/.
  6. package main
  7. import (
  8. "flag"
  9. "fmt"
  10. "log"
  11. "os"
  12. "path/filepath"
  13. "github.com/syncthing/syncthing/lib/db"
  14. )
  15. func main() {
  16. var mode string
  17. log.SetFlags(0)
  18. log.SetOutput(os.Stdout)
  19. flag.StringVar(&mode, "mode", "dump", "Mode of operation: dump, dumpsize")
  20. flag.Parse()
  21. path := flag.Arg(0)
  22. if path == "" {
  23. path = filepath.Join(defaultConfigDir(), "index-v0.14.0.db")
  24. }
  25. fmt.Println("Path:", path)
  26. ldb, err := db.Open(path)
  27. if err != nil {
  28. log.Fatal(err)
  29. }
  30. if mode == "dump" {
  31. dump(ldb)
  32. } else if mode == "dumpsize" {
  33. dumpsize(ldb)
  34. } else {
  35. fmt.Println("Unknown mode")
  36. }
  37. }