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
1f29699d
Commit
1f29699d
authored
Jun 29, 2018
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address c.r. and additional tweaks.
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
parent
8dd970b7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
4 deletions
+13
-4
core/commands/urlstore.go
core/commands/urlstore.go
+6
-1
filestore/filestore_test.go
filestore/filestore_test.go
+1
-1
filestore/fsrefstore.go
filestore/fsrefstore.go
+2
-1
importer/helpers/dagbuilder.go
importer/helpers/dagbuilder.go
+4
-1
No files found.
core/commands/urlstore.go
View file @
1f29699d
...
...
@@ -26,7 +26,7 @@ var urlStoreCmd = &cmds.Command{
var
urlAdd
=
&
cmds
.
Command
{
Helptext
:
cmdkit
.
HelpText
{
Tagline
:
"Add URL
s
via urlstore."
,
Tagline
:
"Add URL via urlstore."
,
LongDescription
:
`
Add URLs to ipfs without storing the data locally.
...
...
@@ -57,6 +57,11 @@ time.
return
}
if
!
filestore
.
IsURL
(
url
)
{
res
.
SetError
(
fmt
.
Errorf
(
"unsupported url syntax: %s"
,
url
),
cmdkit
.
ErrNormal
)
return
}
cfg
,
err
:=
n
.
Repo
.
Config
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
...
...
filestore/filestore_test.go
View file @
1f29699d
...
...
@@ -171,7 +171,7 @@ func TestIsURL(t *testing.T) {
if
!
IsURL
(
"https://www.example.com"
)
{
t
.
Fatal
(
"IsURL failed: https://www.example.com"
)
}
if
IsURL
(
"adir/afile"
)
{
if
IsURL
(
"adir/afile"
)
||
IsURL
(
"http:/ /afile"
)
||
IsURL
(
"http:/a/file"
)
{
t
.
Fatal
(
"IsURL recognized non-url"
)
}
}
filestore/fsrefstore.go
View file @
1f29699d
...
...
@@ -314,7 +314,8 @@ func (f *FileManager) PutMany(bs []*posinfo.FilestoreNode) error {
}
// IsURL returns true if the string represents a valid URL that the
// urlstore can handle.
// urlstore can handle. More specifically it returns true if a string
// begins with 'http://' or 'https://'.
func
IsURL
(
str
string
)
bool
{
return
(
len
(
str
)
>
7
&&
str
[
0
]
==
'h'
&&
str
[
1
]
==
't'
&&
str
[
2
]
==
't'
&&
str
[
3
]
==
'p'
)
&&
((
len
(
str
)
>
8
&&
str
[
4
]
==
's'
&&
str
[
5
]
==
':'
&&
str
[
6
]
==
'/'
&&
str
[
7
]
==
'/'
)
||
...
...
importer/helpers/dagbuilder.go
View file @
1f29699d
...
...
@@ -49,6 +49,9 @@ type DagBuilderParams struct {
// filestore adds
NoCopy
bool
// URL if non-empty (and NoCopy is also true) indicates that the
// file will not be stored in the datastore but instead retrieved
// from this location via the urlstore.
URL
string
}
...
...
@@ -68,7 +71,7 @@ func (dbp *DagBuilderParams) New(spl chunker.Splitter) *DagBuilderHelper {
db
.
stat
=
fi
.
Stat
()
}
if
dbp
.
URL
!=
""
{
if
dbp
.
URL
!=
""
&&
dbp
.
NoCopy
{
db
.
fullPath
=
dbp
.
URL
}
return
db
...
...
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