@@ -17,6 +17,7 @@ import (
17
17
dag "github.com/ipfs/go-ipfs/merkledag"
18
18
dagutils "github.com/ipfs/go-ipfs/merkledag/utils"
19
19
path "github.com/ipfs/go-ipfs/path"
20
+ ft "github.com/ipfs/go-ipfs/unixfs"
20
21
uio "github.com/ipfs/go-ipfs/unixfs/io"
21
22
22
23
humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize"
@@ -153,7 +154,13 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
153
154
ipnsHostname = true
154
155
}
155
156
156
- nd , err := core .Resolve (ctx , i .node , path .Path (urlPath ))
157
+ p , err := path .ParsePath (urlPath )
158
+ if err != nil {
159
+ webError (w , "Invalid Path Error" , err , http .StatusBadRequest )
160
+ return
161
+ }
162
+
163
+ nd , err := core .Resolve (ctx , i .node .Namesys , i .node .Resolver , p )
157
164
// If node is in offline mode the error code and message should be different
158
165
if err == core .ErrNoNamesys && ! i .node .OnlineMode () {
159
166
w .WriteHeader (http .StatusServiceUnavailable )
@@ -240,8 +247,14 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
240
247
return
241
248
}
242
249
250
+ p , err := path .ParsePath (urlPath + "/index.html" )
251
+ if err != nil {
252
+ internalWebError (w , err )
253
+ return
254
+ }
255
+
243
256
// return index page instead.
244
- nd , err := core .Resolve (ctx , i .node , path . Path ( urlPath + "/index.html" ) )
257
+ nd , err := core .Resolve (ctx , i .node . Namesys , i . node . Resolver , p )
245
258
if err != nil {
246
259
internalWebError (w , err )
247
260
return
@@ -356,7 +369,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) {
356
369
357
370
var newnode node.Node
358
371
if rsegs [len (rsegs )- 1 ] == "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" {
359
- newnode = uio . NewEmptyDirectory ()
372
+ newnode = ft . EmptyDirNode ()
360
373
} else {
361
374
putNode , err := i .newDagFromReader (r .Body )
362
375
if err != nil {
@@ -372,7 +385,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) {
372
385
}
373
386
374
387
var newcid * cid.Cid
375
- rnode , err := core .Resolve (ctx , i .node , rootPath )
388
+ rnode , err := core .Resolve (ctx , i .node . Namesys , i . node . Resolver , rootPath )
376
389
switch ev := err .(type ) {
377
390
case path.ErrNoLink :
378
391
// ev.Node < node where resolve failed
@@ -397,7 +410,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) {
397
410
}
398
411
399
412
e := dagutils .NewDagEditor (pbnd , i .node .DAG )
400
- err = e .InsertNodeAtPath (ctx , newPath , newnode , uio . NewEmptyDirectory )
413
+ err = e .InsertNodeAtPath (ctx , newPath , newnode , ft . EmptyDirNode )
401
414
if err != nil {
402
415
webError (w , "putHandler: InsertNodeAtPath failed" , err , http .StatusInternalServerError )
403
416
return
0 commit comments