Skip to content

Commit

Permalink
Working on fspath changes for wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
Simbad Marino authored and Simbad Marino committed Sep 24, 2023
1 parent 7f06ab1 commit 4ef3691
Show file tree
Hide file tree
Showing 68 changed files with 1,559 additions and 24 deletions.
4 changes: 2 additions & 2 deletions cmd/btfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ wasm:
CGO_ENABLED=1 \
GOOS=js \
GOARCH=wasm \
go build -v -trimpath -ldflags="-s -w" -gcflags=all="-l -B" -tags="nofuse purego" -o $(WASM_OUT)/btfs.wasm .
go build -v -trimpath -ldflags="-s -w" -gcflags=all="-l -B" -o $(WASM_OUT)/btfs.wasm .


darwin_m1_macos:
Expand All @@ -117,4 +117,4 @@ darwin_m1_macos:
CGO_CFLAGS="-fembed-bitcode" \
go build -v -trimpath -ldflags="-s -w" -gcflags=all="-l -B" -tags ios -o $(IOS_OUT)/btfs_macOS .

all:linux-amd64 linux-i386 windows-amd64 windows-i386 darwin_m1_macos
all:linux-amd64 linux-i386 windows-amd64 windows-i386 darwin_m1_macos wasm
15 changes: 9 additions & 6 deletions cmd/btfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,36 +119,39 @@ func mainRet() int {

// output depends on executable name passed in os.Args
// so we need to make sure it's stable
//os.Args[0] = "ipfs"
os.Args = append(os.Args, "daemon")
//os.Args[0] = "btfs daemon"
//os.Args[1] = "daemon"

buildEnv := func(ctx context.Context, req *cmds.Request) (cmds.Environment, error) {
checkDebug(req)
repoPath, err := getRepoPath(req)
if err != nil {
return nil, err
}
log.Debugf("config path is %s", repoPath)
//log.Error("config path is %s", repoPath)

plugins, err := loadPlugins(repoPath)
/* plugins, err := loadPlugins(repoPath)
if err != nil {
return nil, err
}
}*/

// this sets up the function that will initialize the node
// this is so that we can construct the node lazily.
return &oldcmds.Context{
ConfigRoot: repoPath,
LoadConfig: loadConfig,
ReqLog: &oldcmds.ReqLog{},
Plugins: plugins,
//Plugins: plugins,
ConstructNode: func() (n *core.IpfsNode, err error) {
if req == nil {
return nil, errors.New("constructing node without a request")
}

//log.Error("About to open")
r, err := fsrepo.Open(repoPath)
if err != nil { // repo is owned by the node
return nil, err
//log.Error("Something failed during opening")
}

// ok everything is good. set it on the invocation (for ownership)
Expand Down
17 changes: 11 additions & 6 deletions core/commands/storage/path/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ var (
PropertiesFileName string
srcProperties string
)

//var btfsrepo embed.FS
/*
can be dir of `btfs` or path like `/private/var/folders/q0/lc8cmwd93gv50ygrsy3bwfyc0000gn/T`,
depends on how `btfs` is called
*/
func init() {
ex, err := os.Executable()
/*ex, err := os.Executable()
if err != nil {
log.Error("err", err)
return
Expand All @@ -64,7 +64,7 @@ func init() {
if err != nil {
log.Errorf("error occurred when remove %s", srcProperties)
}
}
}*/
SetEnvVariables()
}

Expand Down Expand Up @@ -99,7 +99,7 @@ var PathCmd = &cmds.Command{
Tagline: "Modify the Host storage folder path for BTFS client.",
ShortDescription: `
The default local repository path is located at ~/.btfs folder, in order to
improve the hard disk space usage, provide the function to change the original
improve the hard disk space usage, provide the function to change the original
storage location, a specified path as a parameter need to be passed.
`,
},
Expand Down Expand Up @@ -497,8 +497,13 @@ func SetEnvVariables() {
if runtime.GOOS == "android" {
os.Setenv("HOME","/data/data/com.justshare/files/home") // $HOME path definition only
}

if runtime.GOOS == "js" {
os.Setenv("HOME","/btfsrepo") // $HOME path definition only
os.Setenv(BtfsPathKey,"/btfsrepo") //BTFS_PATH envvar definition
}
//TODO: Pending to add $HOME path for iOS
if CheckExist(PropertiesFileName) {
/*if CheckExist(PropertiesFileName) {
btfsPath = ReadProperties(PropertiesFileName)
btfsPath = strings.Trim(btfsPath, " \n\r")
if btfsPath != "" {
Expand All @@ -515,7 +520,7 @@ func SetEnvVariables() {
}
}
}
}
}*/
}

func CheckExist(pathName string) bool {
Expand Down
Binary file added repo/fsrepo/btfsrepo/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions repo/fsrepo/btfsrepo/api
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/ip4/127.0.0.1/tcp/5001
Binary file added repo/fsrepo/btfsrepo/blocks/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.
" ~!l���� '���P�kd�?Ɍ��Z�rabout� /
" A�����(3_LE�ŸN94cn��5��^�"lreadme�


Large diffs are not rendered by default.

Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.
" ~!l���� '���P�kd�?Ɍ��Z�rabout� /
" �O)������w�r,�W�|�K�qqJ�Tk[contactU-
" ^�"fCGA-�I����]��X =������help�/
" A�����(3_LE�ŸN94cn��5��^�"lreadme�


Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
V
" �O)������w�r,�W�|�K�qqJ�Tk[.QmQRNpPs3REpwLPqHg4woE1zogzrwDWfu93bLuBxGQ2gPkU

Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@

�
# 0.1 - Quick Start

This is a set of short examples with minimal explanation. It is meant as
a "quick start".


Add a file to btfs:

echo "hello world" >hello
btfs add hello


View it:

btfs cat <the-hash-you-got-here>


Try a directory:

mkdir foo
mkdir foo/bar
echo "baz" > foo/baz
echo "baz" > foo/bar/baz
btfs add -r foo


View things:

btfs ls <the-hash-here>
btfs ls <the-hash-here>/bar
btfs cat <the-hash-here>/baz
btfs cat <the-hash-here>/bar/baz
btfs cat <the-hash-here>/bar
btfs ls <the-hash-here>/baz


References:

btfs refs <the-hash-here>
btfs refs -r <the-hash-here>
btfs refs --help


Get:

btfs get <the-hash-here> -o foo2
diff foo foo2


Objects:

btfs object get <the-hash-here>
btfs object get <the-hash-here>/foo2
btfs object --help


Pin + GC:

btfs pin add <the-hash-here>
btfs repo gc
btfs ls <the-hash-here>
btfs pin rm <the-hash-here>
btfs repo gc


Daemon:

btfs daemon (in another terminal)
btfs id


Network:

(must be online)
btfs swarm peers
btfs id
btfs cat <hash-of-remote-object>


Mount:

(warning: fuse is finicky!)
btfs mount
cd /btfs/<the-hash-here>
ls


Tool:

btfs version
btfs update
btfs commands
btfs config --help
open http://localhost:5001/webui


Browse:

webui:

http://localhost:5001/webui

�

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

� � Hello and Welcome to BTFS!

██████╗ ████████╗███████╗███████╗
██╔══██╗╚══██╔══╝██╔════╝██╔════╝
██████╔╝ ██║ █████╗ ███████╗
██╔══██╗ ██║ ██╔══╝ ╚════██║
██████╔╝ ██║ ██║ ███████║
╚═════╝ ╚═╝ ╚═╝ ╚══════╝

If you're seeing this, you have successfully installed
BTFS and are now interfacing with the btfs merkledag!

-------------------------------------------------------
| Warning: |
| This is alpha software. Use at your own discretion! |
| Much is missing or lacking polish. There are bugs. |
| Not yet secure. Read the security notes for more. |
-------------------------------------------------------

Check out some of the other files in this directory:

./about
./help
./quick-start <-- usage examples
./readme <-- this file
./security-notes
�
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.
" ~!l���� '���P�kd�?Ɍ��Z�rabout�

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
u
" �n��<Ʊ��ˉ33�k����,��׃I�|��3EK11 años han pasado ya desde que decidimos formar una familia, 4618….pdf��

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@
" vֹ���M E�T��@�fϲ�f'=Y| �IMG_03092023232009.pngŵ


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
W
" ~!l���� '���P�kd�?Ɍ��Z�r.QmWpYr9RJRLMunruPXZ41DbnckR4LtJL6Jph8oQcatcHjf�


Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
V
" hM �8%M9�9�2�UW϶=dY�
-.%�ig.�1.QmVMoFUtFgePXEUVXLTqncgJzEvYD8zNJM1MTVgcs92ADE

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
W
" ^�"fCGA-�I����]��X =������.QmQAMjTXjn9FUJSRjSQGNecyED7kwi3ZjPYunXRJuBTPhr�


Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

��{
"short_name": "BTFS React",
"name": "BTFS React",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "apple-icon.png",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
�
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.
" ~!l���� '���P�kd�?Ɍ��Z�rabout� -
" ^�"fCGA-�I����]��X =������help�/
" A�����(3_LE�ŸN94cn��5��^�"lreadme�

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

��Some helpful resources for finding your way around btfs:

- quick-start: a quick show of various btfs features.
- btfs commands: a list of all commands
- btfs --help: every command describes itself
- https://github.com/TRON-US/go-btfs -- the src repository
�

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions repo/fsrepo/btfsrepo/blocks/SHARDING
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/repo/flatfs/shard/v1/next-to-last/2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

��<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="shortcut icon" href="favicon.ico"/><link rel="apple-touch-icon" sizes="76x76" href="./btfs_logo.png"/><link rel="manifest" href="./manifest.json"/><title>BTFS Dashboard</title><link href="./static/css/antd.7af8fff7.chunk.css" rel="stylesheet"><link href="./static/css/vendor.de0a8c5f.chunk.css" rel="stylesheet"><link href="./static/css/main.eadf0ebb.chunk.css" rel="stylesheet"></head><body class="antialiased helvetica"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,u,i=r[0],c=r[1],s=r[2],l=0,p=[];l<i.length;l++)u=i[l],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&p.push(o[u][0]),o[u]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);p.length;)p.shift()();return a.push.apply(a,s||[]),t()}function t(){for(var e,r=0;r<a.length;r++){for(var t=a[r],n=!0,i=1;i<t.length;i++){var c=t[i];0!==o[c]&&(n=!1)}n&&(a.splice(r--,1),e=u(u.s=t[0]))}return e}var n={},o={10:0},a=[];function u(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,u),t.l=!0,t.exports}u.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var a,i=document.createElement("script");i.charset="utf-8",i.timeout=120,u.nc&&i.setAttribute("nonce",u.nc),i.src=function(e){return u.p+"static/js/"+({2:"cheque~dashboard",4:"cheque",5:"coreVendor",6:"dashboard",7:"files",9:"peers",11:"settings"}[e]||e)+"."+{2:"2357ae95",4:"44576d6b",5:"ff1a6e4d",6:"111db8a6",7:"9383ce5f",9:"fea1c759",11:"45636be2"}[e]+".chunk.js"}(e);var c=new Error;a=function(r){i.onerror=i.onload=null,clearTimeout(s);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+a+")",c.name="ChunkLoadError",c.type=n,c.request=a,t[1](c)}o[e]=void 0}};var s=setTimeout((function(){a({type:"timeout",target:i})}),12e4);i.onerror=i.onload=a,document.head.appendChild(i)}return Promise.all(r)},u.m=e,u.c=n,u.d=function(e,r,t){u.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,r){if(1&r&&(e=u(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(u.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)u.d(t,n,function(r){return e[r]}.bind(null,n));return t},u.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(r,"a",r),r},u.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},u.p="./",u.oe=function(e){throw console.error(e),e};var i=this["webpackJsonpBTFS-Dashboard"]=this["webpackJsonpBTFS-Dashboard"]||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var s=0;s<i.length;s++)r(i[s]);var f=c;t()}([])</script><script src="./static/js/antd.510e9850.chunk.js"></script><script src="./static/js/chart.d3fea5ef.chunk.js"></script><script src="./static/js/vendor.b0bd802c.chunk.js"></script><script src="./static/js/main.deb2b827.chunk.js"></script></body></html>�
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@


btfs
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
W
" A�����(3_LE�ŸN94cn��5��^�"l.QmSnAFu4to9G6VpKSzsc7cQ7cg9TMQYVLbsgsowaPWgxkB�

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

�� BTFS Alpha Security Notes

We try hard to ensure our system is safe and robust, but all software
has bugs, especially new software. This distribution is meant to be an
alpha preview, don't use it for anything mission critical.

Please note the following:

- This is alpha software and has not been audited. It is our goal
to conduct a proper security audit once we close in on a 1.0 release.

- btfs is a networked program, and may have serious undiscovered
vulnerabilities. It is written in Go, and we do not execute any
user provided data. But please point any problems out to us in a
github issue.


- btfs uses encryption for all communication, but it's NOT PROVEN SECURE
YET! It may be totally broken. For now, the code is included to make
sure we benchmark our operations with encryption in mind. In the future,
there will be an "unsafe" mode for high performance intranet apps.
If this is a blocking feature for you, please contact us.
�
Loading

0 comments on commit 4ef3691

Please sign in to comment.