swarm/api: improve FUSE build constraints, logging and APIs (#3818)
* swarm/api: fix build/tests on unsupported platforms Skip FUSE tests if FUSE is unavailable and change build constraints so the 'lesser' platforms aren't mentioned explicitly. The test are compiled on all platforms to prevent regressions in _fallback.go Also gofmt -w -s because why not. * internal/web3ext: fix swarmfs wrappers Remove inputFormatter specifications so users get an error when passing the wrong number of arguments. * swarm/api: improve FUSE-related logging and APIs The API now returns JSON objects instead of strings. Log messages for invalid arguments are removed.
This commit is contained in:
@@ -14,7 +14,9 @@
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// +build !windows
|
||||
// +build linux darwin freebsd
|
||||
|
||||
// Data structures used for Fuse filesystem, serving directories and serving files to Fuse driver.
|
||||
|
||||
package api
|
||||
|
||||
@@ -29,10 +31,6 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
// Data structures used for Fuse filesystem, serving directories and serving files to Fuse driver
|
||||
type FS struct {
|
||||
root *Dir
|
||||
}
|
||||
@@ -55,7 +53,6 @@ type File struct {
|
||||
reader storage.LazySectionReader
|
||||
}
|
||||
|
||||
|
||||
// Functions which satisfy the Fuse File System requests
|
||||
func (filesystem *FS) Root() (fs.Node, error) {
|
||||
return filesystem.root, nil
|
||||
@@ -104,14 +101,12 @@ func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||
}
|
||||
|
||||
func (file *File) Attr(ctx context.Context, a *fuse.Attr) error {
|
||||
|
||||
a.Inode = file.inode
|
||||
//TODO: need to get permission as argument
|
||||
a.Mode = 0500
|
||||
a.Uid = uint32(os.Getuid())
|
||||
a.Gid = uint32(os.Getegid())
|
||||
|
||||
|
||||
reader := file.swarmApi.Retrieve(file.key)
|
||||
quitC := make(chan bool)
|
||||
size, err := reader.Size(quitC)
|
||||
@@ -135,5 +130,4 @@ func (file *File) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.Re
|
||||
}
|
||||
resp.Data = buf[:n]
|
||||
return err
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user