$ npm install -g @jimpick/dat-next
$ mkdir sample-files
$ cd sample-files
$ echo 'Hello world!' > hello-world.txt
$ ls -l
total 8
-rw-r--r-- 1 jim staff 13 Sep 24 09:50 hello-world.txt
(use the --new option to tell the cli to create a "new" multiwriter format archive)
$ dat-next share --new
dat v13.11.3-17
dat://6b96abfccc965b3ab1b3e8bb429850e80740faca06ebea1f6694d02691ec39f3
Format: multiwriter (authorized)
Sharing dat: 1 files (13 B)
0 connections | Download 0 B/s Upload 0 B/s
Watching for file updates
Ctrl+C to Exit
Leave it running for now.
Use the dat://... url that you create in the following steps.
On another computer, install dat-next (npm install -g @jimpick/dat-next
), and
clone the Dat using the url you created:
(Use the --new flag so it knows to expect a new format "multiwriter" archive. In the future, the dat cli will detect the format)
$ dat-next clone --new dat://6b96abfccc965b3ab1b3e8bb429850e80740faca06ebea1f6694d02691ec39f3
dat v13.11.3-17
Created new dat in /Users/jim/tmp/6b96abfccc965b3ab1b3e8bb429850e80740faca06ebea1f6694d02691ec39f3/.dat
dat://6b96abfccc965b3ab1b3e8bb429850e80740faca06ebea1f6694d02691ec39f3
Format: multiwriter (not authorized)
Local key: 9df3edc523cfc995cc854167bc93f52c3c434de58aa027e11bf77fa9a6ccc65d
Cloning: 1 files (13 B)
0 connections | Download 114 B/s Upload 0 B/s
Downloading updates...
[==========================================] 100.00%
Exiting the Dat program...
Make a note of the 'Local key'. You'll use that in a subsequent step to authorize this computer to be able to write to the archive.
$ cd 6b96abfccc965b3ab1b3e8bb429850e80740faca06ebea1f6694d02691ec39f3
$ ls -l
total 8
-rw-r--r-- 1 jim staff 13 Sep 24 09:53 hello-world.txt
$ cat hello-world.txt
Hello world!
First, press Ctrl-C to stop sharing.
Use the 'Local key' that was displayed on the second computer from when you cloned the archive.
$ dat-next authorize 9df3edc523cfc995cc854167bc93f52c3c434de58aa027e11bf77fa9a6ccc65d
Authorization succeeded.
You can now just do dat-next sync
instead of dat-next share --new
. (both are equivalent)
$ dat-next sync
dat v13.11.3-17
dat://6b96abfccc965b3ab1b3e8bb429850e80740faca06ebea1f6694d02691ec39f3
Format: multiwriter (authorized)
Sharing dat: 1 files (0 B)
0 connections | Download 0 B/s Upload 0 B/s
Watching for file updates
Ctrl+C to Exit
We need to do this twice (for now) - the cli doesn't yet have the code written to watch for the authorization change.
First, run dat-next sync
just to sync the changes:
$ dat-next sync
dat v13.11.3-17
dat://6b96abfccc965b3ab1b3e8bb429850e80740faca06ebea1f6694d02691ec39f3
Format: multiwriter (not authorized)
Local key: 9df3edc523cfc995cc854167bc93f52c3c434de58aa027e11bf77fa9a6ccc65d
Sharing dat: 1 files (0 B)
0 connections | Download 0 B/s Upload 0 B/s
Watching for file updates
Ctrl+C to Exit
Then, press Ctrl-C, and then run dat-next sync
again.
$ dat-next sync
dat v13.11.3-17
dat://6b96abfccc965b3ab1b3e8bb429850e80740faca06ebea1f6694d02691ec39f3
Format: multiwriter (authorized)
Sharing dat: 1 files (0 B)
0 connections | Download 0 B/s Upload 0 B/s
Watching for file updates
Ctrl+C to Exit
It says that it is authorized now.
Good. Both computers can now write to the Dat archive. Let's try that out.
On the second computer, leave the dat-next sync
running in one terminal window, and start another terminal.
Make sure you are in the cloned directory (eg. '6b96abfccc965b3ab1b3e8bb429850e80740faca06ebea1f6694d02691ec39f3')
$ basename $PWD
6b96abfccc965b3ab1b3e8bb429850e80740faca06ebea1f6694d02691ec39f3
$ ls -l
total 8
-rw-r--r-- 1 jim staff 13 Sep 24 09:50 hello-world.txt
$ echo 'file from computer 2' > from-computer-2.txt
$ ls -l
total 16
-rw-r--r-- 1 jim staff 21 Sep 24 11:00 from-computer-2.txt
-rw-r--r-- 1 jim staff 13 Sep 24 09:53 hello-world.txt
Since dat-next sync
is open in the same directory in another terminal, the new file should sync across to the first computer.
Open another terminal window on the first computer (in the same 'sample-files' directory), and check it:
$ basename $PWD
sample-files
$ ls -l
total 16
-rw-r--r-- 1 jim staff 21 Sep 24 11:00 from-computer-2.txt
-rw-r--r-- 1 jim staff 13 Sep 24 09:50 hello-world.txt
$ cat from-computer-2.txt
file from computer 2
Warning: This causes the dat-next instance on the second computer to crash
Just to confirm that both ends can still write, in the second terminal window on the first computer (in the 'sample-files' directory):
$ basename $PWD
sample-files
$ ls -l
total 16
-rw-r--r-- 1 jim staff 21 Sep 24 11:00 from-computer-2.txt
-rw-r--r-- 1 jim staff 13 Sep 24 09:50 hello-world.txt
$ echo 'Add a line to hello-world.txt' >> hello-world.txt
jim@jpimac ~/tmp/sample-files $ cat hello-world.txt
Hello world!
Add a line to hello-world.txt
On the second computer, in the the second terminal window:
$ basename $PWD
6b96abfccc965b3ab1b3e8bb429850e80740faca06ebea1f6694d02691ec39f3
$ ls -l
total 16
-rw-r--r-- 1 jim staff 21 Sep 24 11:00 from-computer-2.txt
-rw-r--r-- 1 jim staff 43 Sep 24 11:07 hello-world.txt
$ cat hello-world.txt
Hello world!
Add a line to hello-world.txt
Stack trace for the crash on the last step: