MCPcopy
hub / github.com/containerd/containerd / applyRemove

Method applyRemove

core/mount/manager/manager.go:1065–1115  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1063}
1064
1065func (cc *collectionContext) applyRemove() (map[uint64]struct{}, error) {
1066 remaining := map[uint64]struct{}{}
1067 v1bkt := cc.tx.Bucket([]byte("v1"))
1068 if v1bkt == nil {
1069 return remaining, nil
1070 }
1071 nsc := v1bkt.Cursor()
1072 for nsk, nsv := nsc.First(); nsk != nil; nsk, nsv = nsc.Next() {
1073 if nsv != nil {
1074 continue
1075 }
1076 removed := cc.removed[string(nsk)]
1077 nsbkt := v1bkt.Bucket(nsk)
1078 msbkt := nsbkt.Bucket(bucketKeyMounts)
1079 if msbkt == nil {
1080 continue
1081 }
1082 lsbkt := nsbkt.Bucket(bucketKeyLeases)
1083 msc := msbkt.Cursor()
1084 for msk, msv := msc.First(); msk != nil; msk, msv = msc.Next() {
1085 if msv != nil {
1086 continue
1087 }
1088 mbkt := msbkt.Bucket(msk)
1089 var remove bool
1090 if removed != nil {
1091 _, remove = removed[string(msk)]
1092 }
1093
1094 if remove {
1095 if lsbkt != nil {
1096 lid := mbkt.Get(bucketKeyLease)
1097 if len(lid) > 0 {
1098 lbkt := lsbkt.Bucket(lid)
1099 if lbkt != nil {
1100 lbkt.Delete(msk)
1101 if k, _ := lbkt.Cursor().First(); k == nil {
1102 lsbkt.DeleteBucket(lid)
1103 }
1104 }
1105 }
1106 }
1107 msbkt.DeleteBucket(msk)
1108 } else {
1109 remaining[readID(mbkt)] = struct{}{}
1110 }
1111 }
1112 }
1113
1114 return remaining, nil
1115}
1116
1117func (cc *collectionContext) getCleanupDirectories(remaining map[uint64]struct{}) ([]string, error) {
1118 fd, err := cc.manager.targets.Open(".")

Callers 1

FinishMethod · 0.95

Calls 3

readIDFunction · 0.70
GetMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected