@@ -65,19 +65,17 @@ func (fs *FileStore) initMap() error {
65
65
allocsMap := make (map [string ]* allocation )
66
66
67
67
for _ , dbAlloc := range dbAllocations {
68
+ if dbAlloc .CleanedUp || dbAlloc .Finalized {
69
+ continue
70
+ }
68
71
a := allocation {
69
72
allocatedSize : uint64 (dbAlloc .BlobberSize ),
70
73
mu : & sync.Mutex {},
71
74
tmpMU : & sync.Mutex {},
72
75
}
73
76
74
77
allocsMap [dbAlloc .ID ] = & a
75
- if dbAlloc .StorageVersion == 0 {
76
- err := getStorageDetails (ctx , & a , dbAlloc .ID )
77
- if err != nil {
78
- return err
79
- }
80
- } else {
78
+ if dbAlloc .StorageVersion != 0 {
81
79
a .filesNumber = uint64 (dbAlloc .NumObjects )
82
80
}
83
81
a .filesSize = uint64 (dbAlloc .BlobberSizeUsed )
@@ -156,22 +154,6 @@ func (ref) TableName() string {
156
154
return "reference_objects"
157
155
}
158
156
159
- func getStorageDetails (ctx context.Context , a * allocation , ID string ) error {
160
- db := datastore .GetStore ().GetTransaction (ctx )
161
- r := map [string ]interface {}{
162
- "allocation_id" : ID ,
163
- "type" : "f" ,
164
- }
165
- var totalFiles int64
166
- if err := db .Model (& ref {}).Where (r ).Count (& totalFiles ).Error ; err != nil {
167
- return err
168
- }
169
- a .mu .Lock ()
170
- defer a .mu .Unlock ()
171
- a .filesNumber = uint64 (totalFiles )
172
- return nil
173
- }
174
-
175
157
// UpdateAllocationMetaData only updates if allocation size has changed or new allocation is allocated. Must use allocationID.
176
158
// Use of allocation Tx might leak memory. allocation size must be of int64 type otherwise it won't be updated
177
159
func (fs * FileStore ) UpdateAllocationMetaData (m map [string ]interface {}) error {
0 commit comments