Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
31b83abf
Commit
31b83abf
authored
9 years ago
by
Henry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http gw: remove newDagEmptyDir helper
parent
96846358
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
+5
-8
core/corehttp/gateway_handler.go
core/corehttp/gateway_handler.go
+5
-8
No files found.
core/corehttp/gateway_handler.go
View file @
31b83abf
...
...
@@ -19,7 +19,6 @@ import (
dag
"github.com/ipfs/go-ipfs/merkledag"
path
"github.com/ipfs/go-ipfs/path"
"github.com/ipfs/go-ipfs/routing"
ufs
"github.com/ipfs/go-ipfs/unixfs"
uio
"github.com/ipfs/go-ipfs/unixfs/io"
u
"github.com/ipfs/go-ipfs/util"
)
...
...
@@ -71,14 +70,12 @@ func (i *gatewayHandler) loadTemplate() error {
// TODO(cryptix): find these helpers somewhere else
func
(
i
*
gatewayHandler
)
newDagFromReader
(
r
io
.
Reader
)
(
*
dag
.
Node
,
error
)
{
// TODO(cryptix): change and remove this helper once PR1136 is merged
// return ufs.AddFromReader(i.node, r.Body)
return
importer
.
BuildDagFromReader
(
r
,
i
.
node
.
DAG
,
i
.
node
.
Pinning
.
GetManual
(),
chunk
.
DefaultSplitter
)
}
func
newDagEmptyDir
()
*
dag
.
Node
{
return
&
dag
.
Node
{
Data
:
ufs
.
FolderPBData
()}
}
// TODO(btc): break this apart into separate handlers using a more expressive muxer
func
(
i
*
gatewayHandler
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
i
.
config
.
Writable
{
...
...
@@ -243,7 +240,7 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) {
}
func
(
i
*
gatewayHandler
)
putEmptyDirHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
newnode
:=
newDagEmptyDir
()
newnode
:=
uio
.
NewDirectory
(
i
.
node
.
DAG
)
.
GetNode
()
key
,
err
:=
i
.
node
.
DAG
.
Add
(
newnode
)
if
err
!=
nil
{
...
...
@@ -269,7 +266,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) {
var
newnode
*
dag
.
Node
if
pathext
[
len
(
pathext
)
-
1
]
==
'/'
{
newnode
=
newDagEmptyDir
()
newnode
=
uio
.
NewDirectory
(
i
.
node
.
DAG
)
.
GetNode
()
}
else
{
newnode
,
err
=
i
.
newDagFromReader
(
r
.
Body
)
if
err
!=
nil
{
...
...
@@ -321,7 +318,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) {
if
_
,
ok
:=
err
.
(
path
.
ErrNoLink
);
ok
{
// Create empty directories, links will be made further down the code
for
len
(
pathNodes
)
<
len
(
components
)
{
pathNodes
=
append
(
pathNodes
,
newDagEmptyDir
())
pathNodes
=
append
(
pathNodes
,
uio
.
NewDirectory
(
i
.
node
.
DAG
)
.
GetNode
())
}
}
else
if
err
!=
nil
{
webError
(
w
,
"Could not resolve parent object"
,
err
,
http
.
StatusBadRequest
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment