Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 837aad1

Browse files
author
Lars Gierth
committed
Fix AddDir() by switching to up-to-date MultiFileReader
1 parent 057ec9a commit 837aad1

File tree

11 files changed

+250
-3
lines changed

11 files changed

+250
-3
lines changed

package.json

+7
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@
3030
"hash": "QmX3U3YXCQ6UYBxq2LVWF8dARS1hPUTEYLrSx654Qyxyw6",
3131
"name": "go-multiaddr-net",
3232
"version": "1.5.5"
33+
},
34+
{
35+
"author": "keks",
36+
"hash": "QmfDySkRheT56VAKqvM57xsUcfCRPXjYPzFHr4dAGdpyGj",
37+
"name": "go-ipfs-cmdkit",
38+
"version": "0.3.4"
3339
}
3440
],
3541
"gxVersion": "0.7.0",
3642
"language": "go",
3743
"license": "MIT",
3844
"name": "go-ipfs-api",
45+
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
3946
"version": "1.1.1"
4047
}
4148

request.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"os"
1212
"strings"
1313

14-
files "github.com/whyrusleeping/go-multipart-files"
14+
files "github.com/ipfs/go-ipfs-cmdkit/files"
1515
)
1616

1717
type Request struct {

shell.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import (
1515
"strings"
1616
"time"
1717

18+
files "github.com/ipfs/go-ipfs-cmdkit/files"
1819
homedir "github.com/mitchellh/go-homedir"
1920
ma "github.com/multiformats/go-multiaddr"
2021
manet "github.com/multiformats/go-multiaddr-net"
21-
files "github.com/whyrusleeping/go-multipart-files"
2222
tar "github.com/whyrusleeping/tar-utils"
2323
)
2424

@@ -230,7 +230,7 @@ func (s *Shell) AddDir(dir string) (string, error) {
230230
return "", err
231231
}
232232

233-
sf, err := files.NewSerialFile("", dir, stat)
233+
sf, err := files.NewSerialFile(path.Base(dir), dir, false, stat)
234234
if err != nil {
235235
return "", err
236236
}

shell_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ func TestAdd(t *testing.T) {
2525
is.Equal(mhash, "QmUfZ9rAdhV5ioBzXKdUTh2ZNsz9bzbkaLVyQ8uc8pj21F")
2626
}
2727

28+
func TestAddDir(t *testing.T) {
29+
is := is.New(t)
30+
s := NewShell(shellUrl)
31+
32+
cid, err := s.AddDir("./testdata")
33+
is.Nil(err)
34+
is.Equal(cid, "QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv")
35+
}
36+
2837
func TestLocalShell(t *testing.T) {
2938
is := is.New(t)
3039
s := NewLocalShell()

testdata/about

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
IPFS -- Inter-Planetary File system
3+
4+
IPFS is a global, versioned, peer-to-peer filesystem. It combines good ideas
5+
from Git, BitTorrent, Kademlia, SFS, and the Web. It is like a single bit-
6+
torrent swarm, exchanging git objects. IPFS provides an interface as simple
7+
as the HTTP web, but with permanence built in. You can also mount the world
8+
at /ipfs.
9+
10+
IPFS is a protocol:
11+
- defines a content-addressed file system
12+
- coordinates content delivery
13+
- combines Kademlia + BitTorrent + Git
14+
15+
IPFS is a filesystem:
16+
- has directories and files
17+
- mountable filesystem (via FUSE)
18+
19+
IPFS is a web:
20+
- can be used to view documents like the web
21+
- files accessible via HTTP at `http://ipfs.io/<path>`
22+
- browsers or extensions can learn to use `ipfs://` directly
23+
- hash-addressed content guarantees authenticity
24+
25+
IPFS is modular:
26+
- connection layer over any network protocol
27+
- routing layer
28+
- uses a routing layer DHT (kademlia/coral)
29+
- uses a path-based naming service
30+
- uses bittorrent-inspired block exchange
31+
32+
IPFS uses crypto:
33+
- cryptographic-hash content addressing
34+
- block-level deduplication
35+
- file integrity + versioning
36+
- filesystem-level encryption + signing support
37+
38+
IPFS is p2p:
39+
- worldwide peer-to-peer file transfers
40+
- completely decentralized architecture
41+
- **no** central point of failure
42+
43+
IPFS is a cdn:
44+
- add a file to the filesystem locally, and it's now available to the world
45+
- caching-friendly (content-hash naming)
46+
- bittorrent-based bandwidth distribution
47+
48+
IPFS has a name service:
49+
- IPNS, an SFS inspired name system
50+
- global namespace based on PKI
51+
- serves to build trust chains
52+
- compatible with other NSes
53+
- can map DNS, .onion, .bit, etc to IPNS

testdata/contact

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Come hang out in our IRC chat room if you have any questions.
2+
3+
Contact the ipfs dev team:
4+
- Bugs: https://github.com/ipfs/go-ipfs/issues
5+
- Help: irc.freenode.org/#ipfs
6+

testdata/help

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Some helpful resources for finding your way around ipfs:
2+
3+
- quick-start: a quick show of various ipfs features.
4+
- ipfs commands: a list of all commands
5+
- ipfs --help: every command describes itself
6+
- https://github.com/ipfs/go-ipfs -- the src repository
7+
- #ipfs on irc.freenode.org -- the community irc channel

testdata/ping

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ipfs

testdata/quick-start

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# 0.1 - Quick Start
2+
3+
This is a set of short examples with minimal explanation. It is meant as
4+
a "quick start".
5+
6+
7+
Add a file to ipfs:
8+
9+
echo "hello world" >hello
10+
ipfs add hello
11+
12+
13+
View it:
14+
15+
ipfs cat <the-hash-you-got-here>
16+
17+
18+
Try a directory:
19+
20+
mkdir foo
21+
mkdir foo/bar
22+
echo "baz" > foo/baz
23+
echo "baz" > foo/bar/baz
24+
ipfs add -r foo
25+
26+
27+
View things:
28+
29+
ipfs ls <the-hash-here>
30+
ipfs ls <the-hash-here>/bar
31+
ipfs cat <the-hash-here>/baz
32+
ipfs cat <the-hash-here>/bar/baz
33+
ipfs cat <the-hash-here>/bar
34+
ipfs ls <the-hash-here>/baz
35+
36+
37+
References:
38+
39+
ipfs refs <the-hash-here>
40+
ipfs refs -r <the-hash-here>
41+
ipfs refs --help
42+
43+
44+
Get:
45+
46+
ipfs get <the-hash-here> -o foo2
47+
diff foo foo2
48+
49+
50+
Objects:
51+
52+
ipfs object get <the-hash-here>
53+
ipfs object get <the-hash-here>/foo2
54+
ipfs object --help
55+
56+
57+
Pin + GC:
58+
59+
ipfs pin add <the-hash-here>
60+
ipfs repo gc
61+
ipfs ls <the-hash-here>
62+
ipfs pin rm <the-hash-here>
63+
ipfs repo gc
64+
65+
66+
Daemon:
67+
68+
ipfs daemon (in another terminal)
69+
ipfs id
70+
71+
72+
Network:
73+
74+
(must be online)
75+
ipfs swarm peers
76+
ipfs id
77+
ipfs cat <hash-of-remote-object>
78+
79+
80+
Mount:
81+
82+
(warning: fuse is finicky!)
83+
ipfs mount
84+
cd /ipfs/<the-hash-here>
85+
ls
86+
87+
88+
Tool:
89+
90+
ipfs version
91+
ipfs update
92+
ipfs commands
93+
ipfs config --help
94+
open http://localhost:5001/webui
95+
96+
97+
Browse:
98+
99+
webui:
100+
101+
http://localhost:5001/webui
102+
103+
video:
104+
105+
http://localhost:8080/ipfs/QmVc6zuAneKJzicnJpfrqCH9gSy6bz54JhcypfJYhGUFQu/play#/ipfs/QmTKZgRNwDNZwHtJSjCp6r5FYefzpULfy37JvMt9DwvXse
106+
107+
images:
108+
109+
http://localhost:8080/ipfs/QmZpc3HvfjEXvLWGQPWbHk3AjD5j8NEN4gmFN8Jmrd5g83/cs
110+
111+
markdown renderer app:
112+
113+
http://localhost:8080/ipfs/QmX7M9CiYXjVeFnkfVGf3y5ixTZ2ACeSGyL1vBJY1HvQPp/mdown

testdata/readme

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Hello and Welcome to IPFS!
2+
3+
██╗██████╗ ███████╗███████╗
4+
██║██╔══██╗██╔════╝██╔════╝
5+
██║██████╔╝█████╗ ███████╗
6+
██║██╔═══╝ ██╔══╝ ╚════██║
7+
██║██║ ██║ ███████║
8+
╚═╝╚═╝ ╚═╝ ╚══════╝
9+
10+
If you're seeing this, you have successfully installed
11+
IPFS and are now interfacing with the ipfs merkledag!
12+
13+
-------------------------------------------------------
14+
| Warning: |
15+
| This is alpha software. Use at your own discretion! |
16+
| Much is missing or lacking polish. There are bugs. |
17+
| Not yet secure. Read the security notes for more. |
18+
-------------------------------------------------------
19+
20+
Check out some of the other files in this directory:
21+
22+
./about
23+
./help
24+
./quick-start <-- usage examples
25+
./readme <-- this file
26+
./security-notes

testdata/security-notes

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
IPFS Alpha Security Notes
2+
3+
We try hard to ensure our system is safe and robust, but all software
4+
has bugs, especially new software. This distribution is meant to be an
5+
alpha preview, don't use it for anything mission critical.
6+
7+
Please note the following:
8+
9+
- This is alpha software and has not been audited. It is our goal
10+
to conduct a proper security audit once we close in on a 1.0 release.
11+
12+
- ipfs is a networked program, and may have serious undiscovered
13+
vulnerabilities. It is written in Go, and we do not execute any
14+
user provided data. But please point any problems out to us in a
15+
github issue, or email [email protected] privately.
16+
17+
18+
- 4B9665FB 92636D17 7C7A86D3 50AAE8A9 59B13AF3
19+
- https://pgp.mit.edu/pks/lookup?op=get&search=0x50AAE8A959B13AF3
20+
21+
- ipfs uses encryption for all communication, but it's NOT PROVEN SECURE
22+
YET! It may be totally broken. For now, the code is included to make
23+
sure we benchmark our operations with encryption in mind. In the future,
24+
there will be an "unsafe" mode for high performance intranet apps.
25+
If this is a blocking feature for you, please contact us.

0 commit comments

Comments
 (0)