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,12 +278,22 @@ func ForceRemoveAll(path string) error {
|
||||
func cleanupWCOWLayers(root string) error {
|
||||
// See snapshots/windows/windows.go getSnapshotDir()
|
||||
var layerNums []int
|
||||
var rmLayerNums []int
|
||||
if err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
||||
if path != root && info.IsDir() {
|
||||
if layerNum, err := strconv.Atoi(filepath.Base(path)); err == nil {
|
||||
layerNums = append(layerNums, layerNum)
|
||||
name := filepath.Base(path)
|
||||
if strings.HasPrefix(name, "rm-") {
|
||||
layerNum, err := strconv.Atoi(strings.TrimPrefix(name, "rm-"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rmLayerNums = append(rmLayerNums, layerNum)
|
||||
} else {
|
||||
return err
|
||||
layerNum, err := strconv.Atoi(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
layerNums = append(layerNums, layerNum)
|
||||
}
|
||||
return filepath.SkipDir
|
||||
}
|
||||
@ -293,8 +303,14 @@ func cleanupWCOWLayers(root string) error {
|
||||
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 {
|
||||
if err := cleanupWCOWLayer(filepath.Join(root, strconv.Itoa(layerNum))); err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user