Use ExportChanges() in runtime.Diff()
This code was duplicated in two places, one which was unused. This syncs the code and removes the unused version.
This commit is contained in:
parent
006e2a600c
commit
d69a6a20f0
2 changed files with 9 additions and 26 deletions
|
@ -280,11 +280,7 @@ func ChangesDirs(newDir, oldDir string) ([]Change, error) {
|
|||
return newRoot.Changes(oldRoot), nil
|
||||
}
|
||||
|
||||
func ExportChanges(root, rw string) (Archive, error) {
|
||||
changes, err := ChangesDirs(root, rw)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
func ExportChanges(dir string, changes []Change) (Archive, error) {
|
||||
files := make([]string, 0)
|
||||
deletions := make([]string, 0)
|
||||
for _, change := range changes {
|
||||
|
@ -297,5 +293,11 @@ func ExportChanges(root, rw string) (Archive, error) {
|
|||
deletions = append(deletions, filepath.Join(dir, ".wh."+base))
|
||||
}
|
||||
}
|
||||
return TarFilter(root, &TarOptions{Compression: Uncompressed, Recursive: false, Includes: files, CreateFiles: deletions})
|
||||
// FIXME: Why do we create whiteout files inside Tar code ?
|
||||
return TarFilter(dir, &TarOptions{
|
||||
Compression: Uncompressed,
|
||||
Includes: files,
|
||||
Recursive: false,
|
||||
CreateFiles: deletions,
|
||||
})
|
||||
}
|
||||
|
|
21
runtime.go
21
runtime.go
|
@ -18,7 +18,6 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -763,25 +762,7 @@ func (runtime *Runtime) Diff(container *Container) (archive.Archive, error) {
|
|||
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))
|
||||
}
|
||||
}
|
||||
// FIXME: Why do we create whiteout files inside Tar code ?
|
||||
return archive.TarFilter(cDir, &archive.TarOptions{
|
||||
Compression: archive.Uncompressed,
|
||||
Includes: files,
|
||||
Recursive: false,
|
||||
CreateFiles: deletions,
|
||||
})
|
||||
return archive.ExportChanges(cDir, changes)
|
||||
}
|
||||
|
||||
func linkLxcStart(root string) error {
|
||||
|
|
Loading…
Add table
Reference in a new issue