@@ -33,6 +33,10 @@ type mapStorage struct {
33
33
}
34
34
35
35
func (s * mapStorage ) GetCapacity (ctx context.Context ) (blob.Capacity , error ) {
36
+ if err := ctx .Err (); err != nil {
37
+ return blob.Capacity {}, errors .Wrap (err , "get capacity failed" )
38
+ }
39
+
36
40
if s .limit < 0 {
37
41
return blob.Capacity {}, blob .ErrNotAVolume
38
42
}
@@ -47,6 +51,10 @@ func (s *mapStorage) GetCapacity(ctx context.Context) (blob.Capacity, error) {
47
51
}
48
52
49
53
func (s * mapStorage ) GetBlob (ctx context.Context , id blob.ID , offset , length int64 , output blob.OutputBuffer ) error {
54
+ if err := ctx .Err (); err != nil {
55
+ return errors .Wrap (err , "get blob failed" )
56
+ }
57
+
50
58
s .mutex .RLock ()
51
59
defer s .mutex .RUnlock ()
52
60
@@ -82,6 +90,10 @@ func (s *mapStorage) GetBlob(ctx context.Context, id blob.ID, offset, length int
82
90
}
83
91
84
92
func (s * mapStorage ) GetMetadata (ctx context.Context , id blob.ID ) (blob.Metadata , error ) {
93
+ if err := ctx .Err (); err != nil {
94
+ return blob.Metadata {}, errors .Wrap (err , "get metadata failed" )
95
+ }
96
+
85
97
s .mutex .RLock ()
86
98
defer s .mutex .RUnlock ()
87
99
@@ -98,6 +110,10 @@ func (s *mapStorage) GetMetadata(ctx context.Context, id blob.ID) (blob.Metadata
98
110
}
99
111
100
112
func (s * mapStorage ) PutBlob (ctx context.Context , id blob.ID , data blob.Bytes , opts blob.PutOptions ) error {
113
+ if err := ctx .Err (); err != nil {
114
+ return errors .Wrap (err , "pub blob failed" )
115
+ }
116
+
101
117
switch {
102
118
case opts .HasRetentionOptions ():
103
119
return errors .Wrap (blob .ErrUnsupportedPutBlobOption , "blob-retention" )
@@ -134,6 +150,10 @@ func (s *mapStorage) PutBlob(ctx context.Context, id blob.ID, data blob.Bytes, o
134
150
}
135
151
136
152
func (s * mapStorage ) DeleteBlob (ctx context.Context , id blob.ID ) error {
153
+ if err := ctx .Err (); err != nil {
154
+ return errors .Wrap (err , "delete blob failed" )
155
+ }
156
+
137
157
s .mutex .Lock ()
138
158
defer s .mutex .Unlock ()
139
159
@@ -145,6 +165,10 @@ func (s *mapStorage) DeleteBlob(ctx context.Context, id blob.ID) error {
145
165
}
146
166
147
167
func (s * mapStorage ) ListBlobs (ctx context.Context , prefix blob.ID , callback func (blob.Metadata ) error ) error {
168
+ if err := ctx .Err (); err != nil {
169
+ return errors .Wrap (err , "list blobs failed" )
170
+ }
171
+
148
172
s .mutex .RLock ()
149
173
150
174
keys := []blob.ID {}
@@ -184,6 +208,10 @@ func (s *mapStorage) ListBlobs(ctx context.Context, prefix blob.ID, callback fun
184
208
}
185
209
186
210
func (s * mapStorage ) TouchBlob (ctx context.Context , blobID blob.ID , threshold time.Duration ) (time.Time , error ) {
211
+ if err := ctx .Err (); err != nil {
212
+ return time.Time {}, errors .Wrap (err , "touch blob failed" )
213
+ }
214
+
187
215
s .mutex .Lock ()
188
216
defer s .mutex .Unlock ()
189
217
0 commit comments