Remove Differ and Changer interfaces

Add the methods to the Driver interface
to force the drivers to implement the methods
Upstream-commit: 4d1a537433ede2bbc75b0a4817e8121f9e03fd86
Component: engine
This commit is contained in:
Michael Crosby
2013-11-11 12:10:53 -08:00
parent 675c173a12
commit 86d455035f
6 changed files with 30 additions and 57 deletions
+4 -41
View File
@@ -18,7 +18,6 @@ import (
"os"
"os/exec"
"path"
"path/filepath"
"sort"
"strings"
"time"
@@ -734,49 +733,13 @@ func (runtime *Runtime) Unmount(container *Container) error {
}
func (runtime *Runtime) Changes(container *Container) ([]archive.Change, error) {
if changer, ok := runtime.driver.(graphdriver.Changer); ok {
return changer.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)
// FIXME: Remove Changes method from runtime
return runtime.driver.Changes(container.ID)
}
func (runtime *Runtime) Diff(container *Container) (archive.Archive, error) {
if differ, ok := runtime.driver.(graphdriver.Differ); ok {
return differ.Diff(container.ID)
}
changes, err := runtime.Changes(container)
if err != nil {
return nil, err
}
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)
}
files := make([]string, 0)
deletions := make([]string, 0)
for _, change := range changes {
if change.Kind == archive.ChangeModify || change.Kind == archive.ChangeAdd {
files = append(files, change.Path)
}
if change.Kind == archive.ChangeDelete {
base := filepath.Base(change.Path)
dir := filepath.Dir(change.Path)
deletions = append(deletions, filepath.Join(dir, ".wh."+base))
}
}
return archive.TarFilter(cDir, archive.Uncompressed, files, false, deletions)
// FIXME: Remove Diff method from runtime
return runtime.driver.Diff(container.ID)
}
func linkLxcStart(root string) error {