NewSnapshotter returns a Snapshotter which copies layers on the underlying file system. A metadata file is stored under the root.
(root string)
| 38 | // NewSnapshotter returns a Snapshotter which copies layers on the underlying |
| 39 | // file system. A metadata file is stored under the root. |
| 40 | func NewSnapshotter(root string) (snapshots.Snapshotter, error) { |
| 41 | if err := os.MkdirAll(root, 0700); err != nil { |
| 42 | return nil, err |
| 43 | } |
| 44 | ms, err := storage.NewMetaStore(filepath.Join(root, "metadata.db")) |
| 45 | if err != nil { |
| 46 | return nil, err |
| 47 | } |
| 48 | |
| 49 | if err := os.Mkdir(filepath.Join(root, "snapshots"), 0700); err != nil && !os.IsExist(err) { |
| 50 | return nil, err |
| 51 | } |
| 52 | |
| 53 | return &snapshotter{ |
| 54 | root: root, |
| 55 | ms: ms, |
| 56 | }, nil |
| 57 | } |
| 58 | |
| 59 | // Stat returns the info for an active or committed snapshot by name or |
| 60 | // key. |
searching dependent graphs…