Windows: Cleanup rm- prefixed layers
Some layers might be prefixed with rm-, which will result in an error when converting that string into an integer. Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
This commit is contained in:
parent
64291df71b
commit
ca35f4e820
@ -278,13 +278,23 @@ func ForceRemoveAll(path string) error {
|
|||||||
func cleanupWCOWLayers(root string) error {
|
func cleanupWCOWLayers(root string) error {
|
||||||
// See snapshots/windows/windows.go getSnapshotDir()
|
// See snapshots/windows/windows.go getSnapshotDir()
|
||||||
var layerNums []int
|
var layerNums []int
|
||||||
|
var rmLayerNums []int
|
||||||
if err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
if err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
||||||
if path != root && info.IsDir() {
|
if path != root && info.IsDir() {
|
||||||
if layerNum, err := strconv.Atoi(filepath.Base(path)); err == nil {
|
name := filepath.Base(path)
|
||||||
layerNums = append(layerNums, layerNum)
|
if strings.HasPrefix(name, "rm-") {
|
||||||
} else {
|
layerNum, err := strconv.Atoi(strings.TrimPrefix(name, "rm-"))
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
rmLayerNums = append(rmLayerNums, layerNum)
|
||||||
|
} else {
|
||||||
|
layerNum, err := strconv.Atoi(name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
layerNums = append(layerNums, layerNum)
|
||||||
|
}
|
||||||
return filepath.SkipDir
|
return filepath.SkipDir
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,8 +303,14 @@ func cleanupWCOWLayers(root string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(sort.Reverse(sort.IntSlice(layerNums)))
|
sort.Sort(sort.Reverse(sort.IntSlice(rmLayerNums)))
|
||||||
|
for _, rmLayerNum := range rmLayerNums {
|
||||||
|
if err := cleanupWCOWLayer(filepath.Join(root, "rm-"+strconv.Itoa(rmLayerNum))); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Sort(sort.Reverse(sort.IntSlice(layerNums)))
|
||||||
for _, layerNum := range layerNums {
|
for _, layerNum := range layerNums {
|
||||||
if err := cleanupWCOWLayer(filepath.Join(root, strconv.Itoa(layerNum))); err != nil {
|
if err := cleanupWCOWLayer(filepath.Join(root, strconv.Itoa(layerNum))); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user