@@ -12,7 +12,6 @@ import (
12
12
lassie "github.com/filecoin-project/lassie/pkg/lassie"
13
13
"github.com/filecoin-project/lassie/pkg/retriever"
14
14
"github.com/filecoin-project/lassie/pkg/storage"
15
- "github.com/filecoin-project/lassie/pkg/storage/limitstore"
16
15
"github.com/filecoin-project/lassie/pkg/types"
17
16
"github.com/ipfs/go-cid"
18
17
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
@@ -176,21 +175,6 @@ func ipfsHandler(lassie *lassie.Lassie, cfg HttpServerConfig) func(http.Response
176
175
}()
177
176
var store types.ReadableWritableStorage = carStore
178
177
179
- // extract block limit from query param as needed
180
- var blockLimit uint64
181
- if req .URL .Query ().Has ("blockLimit" ) {
182
- if parsedBlockLimit , err := strconv .ParseUint (req .URL .Query ().Get ("blockLimit" ), 10 , 64 ); err == nil {
183
- blockLimit = parsedBlockLimit
184
- }
185
- }
186
- if cfg .MaxBlocksPerRequest > 0 || blockLimit > 0 {
187
- // use the lowest non-zero value for block limit
188
- if blockLimit == 0 || (cfg .MaxBlocksPerRequest > 0 && blockLimit > cfg .MaxBlocksPerRequest ) {
189
- blockLimit = cfg .MaxBlocksPerRequest
190
- }
191
- store = limitstore .NewLimitStore (carStore , blockLimit )
192
- }
193
-
194
178
carWriter .OnPut (func (int ) {
195
179
// called once we start writing blocks into the CAR (on the first Put())
196
180
res .Header ().Set ("Content-Disposition" , "attachment; filename=" + filename )
@@ -224,7 +208,22 @@ func ipfsHandler(lassie *lassie.Lassie, cfg HttpServerConfig) func(http.Response
224
208
request .PreloadLinkSystem .SetWriteStorage (preloadStore )
225
209
request .PreloadLinkSystem .TrustedStorage = true
226
210
227
- log .Debugw ("fetching CID" , "retrievalId" , retrievalId , "CID" , rootCid .String (), "path" , unixfsPath , "carScope" , carScope )
211
+ // extract block limit from query param as needed
212
+ var blockLimit uint64
213
+ if req .URL .Query ().Has ("blockLimit" ) {
214
+ if parsedBlockLimit , err := strconv .ParseUint (req .URL .Query ().Get ("blockLimit" ), 10 , 64 ); err == nil {
215
+ blockLimit = parsedBlockLimit
216
+ }
217
+ }
218
+ if cfg .MaxBlocksPerRequest > 0 || blockLimit > 0 {
219
+ // use the lowest non-zero value for block limit
220
+ if blockLimit == 0 || (cfg .MaxBlocksPerRequest > 0 && blockLimit > cfg .MaxBlocksPerRequest ) {
221
+ blockLimit = cfg .MaxBlocksPerRequest
222
+ }
223
+ request .MaxBlocks = blockLimit
224
+ }
225
+
226
+ log .Debugw ("fetching CID" , "retrievalId" , retrievalId , "CID" , rootCid .String (), "path" , unixfsPath , "carScope" , carScope )
228
227
stats , err := lassie .Fetch (req .Context (), request , func (re types.RetrievalEvent ) {
229
228
header := servertiming .FromContext (req .Context ())
230
229
if header == nil {
0 commit comments