mirror of https://github.com/docker/docs.git
Don't rely on drivers for diff and export
This commit is contained in:
parent
1764cf1990
commit
99210c9c6e
|
@ -206,3 +206,25 @@ func ChangesDirs(newDir, oldDir string) ([]Change, error) {
|
|||
}
|
||||
return changes, nil
|
||||
}
|
||||
|
||||
|
||||
func ExportChanges(root, rw string) (Archive, error) {
|
||||
changes, err := ChangesDirs(root, rw)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
files := make([]string, 0)
|
||||
deletions := make([]string, 0)
|
||||
for _, change := range changes {
|
||||
if change.Kind == ChangeModify || change.Kind == ChangeAdd {
|
||||
files = append(files, change.Path)
|
||||
}
|
||||
if change.Kind == ChangeDelete {
|
||||
base := filepath.Base(change.Path)
|
||||
dir := filepath.Dir(change.Path)
|
||||
deletions = append(deletions, filepath.Join(dir, ".wh."+base))
|
||||
}
|
||||
}
|
||||
return TarFilter(root, Uncompressed, files, false, deletions)
|
||||
}
|
||||
|
||||
|
|
|
@ -1363,10 +1363,17 @@ func (container *Container) Resize(h, w int) error {
|
|||
}
|
||||
|
||||
func (container *Container) ExportRw() (archive.Archive, error) {
|
||||
if err := container.EnsureMounted(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if container.runtime == nil {
|
||||
return nil, fmt.Errorf("Can't load storage driver for unregistered container %s", container.ID)
|
||||
}
|
||||
return container.runtime.driver.Diff(container.ID)
|
||||
imgDir, err := container.runtime.driver.Get(container.Image)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return archive.ExportChanges(container.RootfsPath(), imgDir)
|
||||
}
|
||||
|
||||
func (container *Container) Export() (archive.Archive, error) {
|
||||
|
|
10
runtime.go
10
runtime.go
|
@ -733,7 +733,15 @@ func (runtime *Runtime) Unmount(container *Container) error {
|
|||
}
|
||||
|
||||
func (runtime *Runtime) Changes(container *Container) ([]archive.Change, error) {
|
||||
return runtime.driver.Changes(container.ID)
|
||||
cDir, err := runtime.driver.Get(container.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error getting container rootfs %s from driver %s: %s", container.ID, container.runtime.driver, err)
|
||||
}
|
||||
initDir, err := runtime.driver.Get(container.ID + "-init")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error getting container init rootfs %s from driver %s: %s", container.ID, container.runtime.driver, err)
|
||||
}
|
||||
return archive.ChangesDirs(cDir, initDir)
|
||||
}
|
||||
|
||||
func linkLxcStart(root string) error {
|
||||
|
|
Loading…
Reference in New Issue