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
d588636c
Commit
d588636c
authored
10 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove 'Open' from ipnsfs
parent
f679127d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
163 deletions
+0
-163
ipnsfs/dir.go
ipnsfs/dir.go
+0
-32
ipnsfs/system.go
ipnsfs/system.go
+0
-37
ipnsfs/system_test.go
ipnsfs/system_test.go
+0
-94
No files found.
ipnsfs/dir.go
View file @
d588636c
...
...
@@ -38,38 +38,6 @@ func NewDirectory(name string, node *dag.Node, parent childCloser, fs *Filesyste
}
}
// Open opens a file at the given path 'tpath'
func
(
d
*
Directory
)
Open
(
tpath
[]
string
,
mode
int
)
(
*
File
,
error
)
{
if
len
(
tpath
)
==
0
{
return
nil
,
ErrIsDirectory
}
if
len
(
tpath
)
==
1
{
fi
,
err
:=
d
.
childFile
(
tpath
[
0
])
if
err
==
nil
{
return
fi
,
nil
}
if
mode
|
os
.
O_CREATE
!=
0
{
fnode
:=
new
(
dag
.
Node
)
fnode
.
Data
=
ft
.
FilePBData
(
nil
,
0
)
nfi
,
err
:=
NewFile
(
tpath
[
0
],
fnode
,
d
,
d
.
fs
)
if
err
!=
nil
{
return
nil
,
err
}
d
.
files
[
tpath
[
0
]]
=
nfi
return
nfi
,
nil
}
return
nil
,
os
.
ErrNotExist
}
dir
,
err
:=
d
.
childDir
(
tpath
[
0
])
if
err
!=
nil
{
return
nil
,
err
}
return
dir
.
Open
(
tpath
[
1
:
],
mode
)
}
// closeChild updates the child by the given name to the dag node 'nd'
// and changes its own dag node, then propogates the changes upward
func (d *Directory) closeChild(name string, nd *dag.Node) error {
...
...
This diff is collapsed.
Click to expand it.
ipnsfs/system.go
View file @
d588636c
...
...
@@ -14,7 +14,6 @@ import (
"errors"
"fmt"
"os"
"strings"
"sync"
"time"
...
...
@@ -69,17 +68,6 @@ func NewFilesystem(ctx context.Context, ds dag.DAGService, nsys namesys.NameSyst
return
fs
,
nil
}
// Open opens a file at the given path
func
(
fs
*
Filesystem
)
Open
(
tpath
string
,
mode
int
)
(
*
File
,
error
)
{
pathelem
:=
strings
.
Split
(
tpath
,
"/"
)
r
,
ok
:=
fs
.
roots
[
pathelem
[
0
]]
if
!
ok
{
return
nil
,
os
.
ErrNotExist
}
return
r
.
Open
(
pathelem
[
1
:
],
mode
)
}
func
(
fs
*
Filesystem
)
Close
()
error
{
wg
:=
sync
.
WaitGroup
{}
for
_
,
r
:=
range
fs
.
roots
{
...
...
@@ -206,31 +194,6 @@ func (kr *KeyRoot) GetValue() FSNode {
return
kr
.
val
}
func
(
kr
*
KeyRoot
)
Open
(
tpath
[]
string
,
mode
int
)
(
*
File
,
error
)
{
if
kr
.
val
==
nil
{
// No entry here. KeyRoot was created incorrectly
panic
(
"nil keyroot.val, improperly constructed keyroot"
)
}
if
len
(
tpath
)
>
0
{
// Make sure our root is a directory
dir
,
ok
:=
kr
.
val
.
(
*
Directory
)
if
!
ok
{
return
nil
,
os
.
ErrNotExist
}
return
dir
.
Open
(
tpath
,
mode
)
}
switch
t
:=
kr
.
val
.
(
type
)
{
case
*
Directory
:
return
nil
,
ErrIsDirectory
case
*
File
:
return
t
,
nil
default
:
panic
(
"unrecognized type, should not happen"
)
}
}
// closeChild implements the childCloser interface, and signals to the publisher that
// there are changes ready to be published
func
(
kr
*
KeyRoot
)
closeChild
(
name
string
,
nd
*
dag
.
Node
)
error
{
...
...
This diff is collapsed.
Click to expand it.
ipnsfs/system_test.go
deleted
100644 → 0
View file @
f679127d
package
ipnsfs_test
import
(
"bytes"
"io/ioutil"
"os"
"path"
"testing"
core
"github.com/jbenet/go-ipfs/core"
.
"github.com/jbenet/go-ipfs/ipnsfs"
u
"github.com/jbenet/go-ipfs/util"
)
func
testFS
(
t
*
testing
.
T
,
nd
*
core
.
IpfsNode
)
*
Filesystem
{
fs
,
err
:=
NewFilesystem
(
nd
.
Context
(),
nd
.
DAG
,
nd
.
Namesys
,
nd
.
Pinning
,
nd
.
PrivateKey
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
return
fs
}
// Test some basic operations
// testing in fuse/ipns is sufficient to prove this code works properly
func
TestBasic
(
t
*
testing
.
T
)
{
mock
,
err
:=
core
.
NewMockNode
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
fs
:=
testFS
(
t
,
mock
)
k
:=
u
.
Key
(
mock
.
Identity
)
p
:=
path
.
Join
(
k
.
B58String
(),
"file"
)
fi
,
err
:=
fs
.
Open
(
p
,
os
.
O_CREATE
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
data
:=
[]
byte
(
"Hello World"
)
n
,
err
:=
fi
.
Write
(
data
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
n
!=
len
(
data
)
{
t
.
Fatal
(
"wrote incorrect amount"
)
}
err
=
fi
.
Close
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
nfi
,
err
:=
fs
.
Open
(
p
,
os
.
O_RDONLY
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
out
,
err
:=
ioutil
.
ReadAll
(
nfi
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
nfi
.
Close
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
!
bytes
.
Equal
(
out
,
data
)
{
t
.
Fatal
(
"Write failed."
)
}
err
=
fs
.
Close
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// Open the filesystem again, and try to read our file
nfs
:=
testFS
(
t
,
mock
)
fi
,
err
=
nfs
.
Open
(
p
,
os
.
O_RDONLY
)
nb
,
err
:=
ioutil
.
ReadAll
(
fi
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
t
.
Log
(
nb
)
if
!
bytes
.
Equal
(
nb
,
data
)
{
t
.
Fatal
(
"data not the same after closing down fs"
)
}
}
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