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
b182e539
Commit
b182e539
authored
Jan 15, 2016
by
Jeromy Johnson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2202 from noffle/hidden_files-2145
Lets 'ipfs add' include top-level hidden files
parents
3d58888d
0828d1eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
12 deletions
+34
-12
core/commands/add.go
core/commands/add.go
+16
-3
core/coreunix/add.go
core/coreunix/add.go
+7
-9
test/sharness/t0042-add-skip.sh
test/sharness/t0042-add-skip.sh
+11
-0
No files found.
core/commands/add.go
View file @
b182e539
...
...
@@ -2,6 +2,7 @@ package commands
import
(
"fmt"
"io"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/cheggaaa/pb"
"github.com/ipfs/go-ipfs/core/coreunix"
...
...
@@ -49,7 +50,7 @@ remains to be implemented.
cmds
.
BoolOption
(
trickleOptionName
,
"t"
,
"Use trickle-dag format for dag generation"
),
cmds
.
BoolOption
(
onlyHashOptionName
,
"n"
,
"Only chunk and hash - do not write to disk"
),
cmds
.
BoolOption
(
wrapOptionName
,
"w"
,
"Wrap files with a directory object"
),
cmds
.
BoolOption
(
hiddenOptionName
,
"H"
,
"Include files that are hidden"
),
cmds
.
BoolOption
(
hiddenOptionName
,
"H"
,
"Include files that are hidden
. Only takes effect on recursive add.
"
),
cmds
.
StringOption
(
chunkerOptionName
,
"s"
,
"chunking algorithm to use"
),
cmds
.
BoolOption
(
pinOptionName
,
"Pin this object when adding. Default true"
),
},
...
...
@@ -147,8 +148,20 @@ remains to be implemented.
fileAdder
.
Silent
=
silent
addAllAndPin
:=
func
(
f
files
.
File
)
error
{
if
err
:=
fileAdder
.
AddFile
(
f
);
err
!=
nil
{
return
err
// Iterate over each top-level file and add individually. Otherwise the
// single files.File f is treated as a directory, affecting hidden file
// semantics.
for
{
file
,
err
:=
f
.
NextFile
()
if
err
==
io
.
EOF
{
// Finished the list of files.
break
}
else
if
err
!=
nil
{
return
err
}
if
err
:=
fileAdder
.
AddFile
(
file
);
err
!=
nil
{
return
err
}
}
if
hash
{
...
...
core/coreunix/add.go
View file @
b182e539
...
...
@@ -359,11 +359,7 @@ func (adder *Adder) addFile(file files.File) error {
return
err
}
switch
{
case
files
.
IsHidden
(
file
)
&&
!
adder
.
Hidden
:
log
.
Infof
(
"%s is hidden, skipping"
,
file
.
FileName
())
return
&
hiddenFileError
{
file
.
FileName
()}
case
file
.
IsDirectory
()
:
if
file
.
IsDirectory
()
{
return
adder
.
addDir
(
file
)
}
...
...
@@ -417,11 +413,13 @@ func (adder *Adder) addDir(dir files.File) error {
break
}
err
=
adder
.
addFile
(
file
)
if
_
,
ok
:=
err
.
(
*
h
idden
F
ile
Error
);
ok
{
// hidden file error, skip file
// Skip hidden files when adding recursively, unless Hidden is enabled.
if
files
.
IsH
idden
(
f
ile
)
&&
!
adder
.
Hidden
{
log
.
Infof
(
"%s is hidden, skipping"
,
file
.
FileName
())
continue
}
else
if
err
!=
nil
{
}
err
=
adder
.
addFile
(
file
)
if
err
!=
nil
{
return
err
}
}
...
...
test/sharness/t0042-add-skip.sh
View file @
b182e539
...
...
@@ -48,6 +48,17 @@ test_add_skip() {
test_cmp expected actual
'
test_expect_success
"'ipfs add' includes hidden files given explicitly even without --hidden"
'
mkdir -p mountdir/dotfiles &&
echo "set nocompatible" > mountdir/dotfiles/.vimrc
cat >expected <<-\EOF &&
added QmT4uMRDCN7EMpFeqwvKkboszbqeW1kWVGrBxBuCGqZcQc .vimrc
EOF
ipfs add mountdir/dotfiles/.vimrc >actual
cat actual
test_cmp expected actual
'
}
# should work offline
...
...
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