| 25 | ) |
| 26 | |
| 27 | func loadSnapshot(snapshotFileName string) (*snapshot, error) { |
| 28 | logger.Infof("opening snapshot file %s", snapshotFileName) |
| 29 | snapshotFile, err := os.Open(snapshotFileName) |
| 30 | if err != nil { |
| 31 | logger.Errorf("cannot open %s: %v", snapshotFileName, err) |
| 32 | return nil, err |
| 33 | } |
| 34 | defer snapshotFile.Close() |
| 35 | |
| 36 | logger.Infof("decoding snapshot file %s", snapshotFileName) |
| 37 | s := &snapshot{} |
| 38 | decoder := gob.NewDecoder(snapshotFile) |
| 39 | if err = decoder.Decode(s); err != nil { |
| 40 | logger.Errorf("cannot decode %s: %v", snapshotFileName, err) |
| 41 | return nil, err |
| 42 | } |
| 43 | |
| 44 | return s, nil |
| 45 | } |
| 46 | |
| 47 | func localCommand() error { |
| 48 | if *flagSnapshot == "" { |