Fixes missing whiteout parent directories
Ensures include parents is called for whiteouts Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
parent
254807da5b
commit
d778dd15d8
@ -436,6 +436,9 @@ func (cw *changeWriter) HandleChange(k fs.ChangeKind, p string, f os.FileInfo, e
|
|||||||
AccessTime: cw.whiteoutT,
|
AccessTime: cw.whiteoutT,
|
||||||
ChangeTime: cw.whiteoutT,
|
ChangeTime: cw.whiteoutT,
|
||||||
}
|
}
|
||||||
|
if err := cw.includeParents(hdr); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := cw.tw.WriteHeader(hdr); err != nil {
|
if err := cw.tw.WriteHeader(hdr); err != nil {
|
||||||
return errors.Wrap(err, "failed to write whiteout header")
|
return errors.Wrap(err, "failed to write whiteout header")
|
||||||
}
|
}
|
||||||
|
@ -874,6 +874,7 @@ func TestDiffTar(t *testing.T) {
|
|||||||
fileEntry("d3/l1", []byte("link me"), 0644),
|
fileEntry("d3/l1", []byte("link me"), 0644),
|
||||||
dirEntry("d4/", 0755),
|
dirEntry("d4/", 0755),
|
||||||
linkEntry("d4/f1", "d3/l1"),
|
linkEntry("d4/f1", "d3/l1"),
|
||||||
|
dirEntry("d6/", 0755),
|
||||||
whiteoutEntry("d6/l1"),
|
whiteoutEntry("d6/l1"),
|
||||||
whiteoutEntry("d6/l2"),
|
whiteoutEntry("d6/l2"),
|
||||||
},
|
},
|
||||||
@ -947,6 +948,46 @@ func TestDiffTar(t *testing.T) {
|
|||||||
fstest.Link("/d3/f1", "/d4/l1"),
|
fstest.Link("/d3/f1", "/d4/l1"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "WhiteoutIncludesParents",
|
||||||
|
validators: []tarEntryValidator{
|
||||||
|
dirEntry("d1/", 0755),
|
||||||
|
whiteoutEntry("d1/f1"),
|
||||||
|
dirEntry("d2/", 0755),
|
||||||
|
whiteoutEntry("d2/f1"),
|
||||||
|
fileEntry("d2/f2", []byte("content"), 0777),
|
||||||
|
dirEntry("d3/", 0755),
|
||||||
|
whiteoutEntry("d3/f1"),
|
||||||
|
fileEntry("d3/f2", []byte("content"), 0644),
|
||||||
|
dirEntry("d4/", 0755),
|
||||||
|
fileEntry("d4/f0", []byte("content"), 0644),
|
||||||
|
whiteoutEntry("d4/f1"),
|
||||||
|
whiteoutEntry("d5"),
|
||||||
|
},
|
||||||
|
a: fstest.Apply(
|
||||||
|
fstest.CreateDir("/d1/", 0755),
|
||||||
|
fstest.CreateFile("/d1/f1", []byte("content"), 0644),
|
||||||
|
fstest.CreateDir("/d2/", 0755),
|
||||||
|
fstest.CreateFile("/d2/f1", []byte("content"), 0644),
|
||||||
|
fstest.CreateFile("/d2/f2", []byte("content"), 0644),
|
||||||
|
fstest.CreateDir("/d3/", 0755),
|
||||||
|
fstest.CreateFile("/d3/f1", []byte("content"), 0644),
|
||||||
|
fstest.CreateDir("/d4/", 0755),
|
||||||
|
fstest.CreateFile("/d4/f1", []byte("content"), 0644),
|
||||||
|
fstest.CreateDir("/d5/", 0755),
|
||||||
|
fstest.CreateFile("/d5/f1", []byte("content"), 0644),
|
||||||
|
),
|
||||||
|
b: fstest.Apply(
|
||||||
|
fstest.Remove("/d1/f1"),
|
||||||
|
fstest.Remove("/d2/f1"),
|
||||||
|
fstest.Chmod("/d2/f2", 0777),
|
||||||
|
fstest.Remove("/d3/f1"),
|
||||||
|
fstest.CreateFile("/d3/f2", []byte("content"), 0644),
|
||||||
|
fstest.Remove("/d4/f1"),
|
||||||
|
fstest.CreateFile("/d4/f0", []byte("content"), 0644),
|
||||||
|
fstest.RemoveAll("/d5"),
|
||||||
|
),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, at := range tests {
|
for _, at := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user