@@ -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"
@@ -173,21 +172,6 @@ func ipfsHandler(lassie *lassie.Lassie, cfg HttpServerConfig) func(http.Response
173
172
}()
174
173
var store types.ReadableWritableStorage = carStore
175
174
176
- // extract block limit from query param as needed
177
- var blockLimit uint64
178
- if req .URL .Query ().Has ("blockLimit" ) {
179
- if parsedBlockLimit , err := strconv .ParseUint (req .URL .Query ().Get ("blockLimit" ), 10 , 64 ); err == nil {
180
- blockLimit = parsedBlockLimit
181
- }
182
- }
183
- if cfg .MaxBlocksPerRequest > 0 || blockLimit > 0 {
184
- // use the lowest non-zero value for block limit
185
- if blockLimit == 0 || (cfg .MaxBlocksPerRequest > 0 && blockLimit > cfg .MaxBlocksPerRequest ) {
186
- blockLimit = cfg .MaxBlocksPerRequest
187
- }
188
- store = limitstore .NewLimitStore (carStore , blockLimit )
189
- }
190
-
191
175
carWriter .OnPut (func (int ) {
192
176
// called once we start writing blocks into the CAR (on the first Put())
193
177
res .Header ().Set ("Content-Disposition" , "attachment; filename=" + filename )
@@ -221,6 +205,21 @@ func ipfsHandler(lassie *lassie.Lassie, cfg HttpServerConfig) func(http.Response
221
205
request .PreloadLinkSystem .SetWriteStorage (preloadStore )
222
206
request .PreloadLinkSystem .TrustedStorage = true
223
207
208
+ // extract block limit from query param as needed
209
+ var blockLimit uint64
210
+ if req .URL .Query ().Has ("blockLimit" ) {
211
+ if parsedBlockLimit , err := strconv .ParseUint (req .URL .Query ().Get ("blockLimit" ), 10 , 64 ); err == nil {
212
+ blockLimit = parsedBlockLimit
213
+ }
214
+ }
215
+ if cfg .MaxBlocksPerRequest > 0 || blockLimit > 0 {
216
+ // use the lowest non-zero value for block limit
217
+ if blockLimit == 0 || (cfg .MaxBlocksPerRequest > 0 && blockLimit > cfg .MaxBlocksPerRequest ) {
218
+ blockLimit = cfg .MaxBlocksPerRequest
219
+ }
220
+ request .MaxBlocks = blockLimit
221
+ }
222
+
224
223
log .Debugw ("fetching CID" , "retrievalId" , retrievalId , "CID" , rootCid .String (), "path" , unixfsPath , "fullFetch" , fullFetch )
225
224
stats , err := lassie .Fetch (req .Context (), request )
226
225
if err != nil {
0 commit comments