git ssb

0+

clemo / ssb-ipfs-share



forked from arj / dat-share

Commit 338baa22ed1a31664b6306c3b58352e256a469ea

Allow memory sharing instead of filesystem

Anders Rune Jensen committed on 9/27/2017, 6:16:21 PM
Parent: 589659eb2f7557af64874b5dc925456e0cc0764a

Files changed

README.mdchanged
bin.jschanged
index.jschanged
lib.jschanged
package.jsonchanged
README.mdView
@@ -7,9 +7,11 @@
77 ```
88 node bin.js -f ./dats
99 ```
1010
11-Can also take a -i option to only share links from people you follow.
11+Can also take a -i option to only share links from people you
12+follow. And can be told to share using memory (-t) instead of from
13+filesystem.
1214
1315 This should give you something like this:
1416
1517 ```
@@ -44,6 +46,4 @@
4446
4547 https://github.com/datproject/dat-node
4648
4749 - var stats = dat.trackStats(), peers
48- - temp: false, // Use random-access-memory as the storage.
49-
bin.jsView
@@ -6,18 +6,22 @@
66
77 program
88 .option('-f, --share-folder [value]', 'Folder for sharing')
99 .option('-i, --only-people-i-follow', 'Only seed urls from people or channels I follow')
10+ .option('-t, --temp', 'Use memory instead of filesystem for sharing')
1011 .parse(process.argv);
1112
1213 require('ssb-client')((err, sbot) => {
1314 if (err) throw err;
1415
1516 var shareFolder = program.shareFolder || '/tmp'
16-
17- console.log("Sharing dat links from:", shareFolder)
1817
18+ if (program.temp)
19+ console.log("Sharing dat links in memory mode instead of filesytem")
20+ else
21+ console.log("Sharing dat links from:", shareFolder)
22+
1923 if (program.onlyPeopleIFollow)
20- lib.getFromPeopleIFollow(sbot, shareFolder)
24+ lib.getFromPeopleIFollow(sbot, shareFolder, program.temp)
2125 else
22- lib.getAll(sbot, shareFolder)
26+ lib.getAll(sbot, shareFolder, program.temp)
2327 })
index.jsView
@@ -10,8 +10,8 @@
1010
1111 console.log("Sharing dat links from:", shareFolder)
1212
1313 if (conf.onlyPeopleIFollow)
14- lib.getFromPeopleIFollow(ssb, shareFolder)
14+ lib.getFromPeopleIFollow(ssb, shareFolder, conf.temp)
1515 else
16- lib.getAll(ssb, shareFolder)
16+ lib.getAll(ssb, shareFolder, conf.temp)
1717 }
lib.jsView
@@ -2,9 +2,9 @@
22 var uri = require('urijs')
33 var pull = require('pull-stream')
44
55 var self = module.exports = {
6- extractLinksAndSeed: function(err, logs, shareFolder) {
6+ extractLinksAndSeed: function(err, logs, shareFolder, useTemp) {
77 if (err) throw err;
88
99 console.log("Found " + logs.length)
1010
@@ -14,9 +14,10 @@
1414
1515 console.log("Saving to:", shareFolder + "/" + datLink.substring(6))
1616
1717 Dat(shareFolder + "/" + datLink.substring(6), {
18- key: datLink
18+ key: datLink,
19+ temp: useTemp
1920 }, function (err, dat) {
2021 if (err) throw err
2122
2223 console.log("sharing:", datLink)
@@ -25,9 +26,9 @@
2526 })
2627 })
2728 },
2829
29- getAll: function(sbot, shareFolder) {
30+ getAll: function(sbot, shareFolder, useTemp) {
3031 console.log("Looking for dat links in all feeds")
3132
3233 pull(
3334 sbot.createLogStream({ live: true, reverse: true, limit: 10000 }),
@@ -37,15 +38,16 @@
3738 typeof msg.value.content.text == "string" &&
3839 msg.value.content.text.indexOf("dat://") != -1
3940 }),
4041 pull.collect((err, logs) => self.extractLinksAndSeed(err, logs,
41- shareFolder))
42+ shareFolder,
43+ useTemp))
4244 )
4345 },
4446
4547 messagesFromPeopleIFollow: function(sbot, following,
4648 channelSubscriptions,
47- shareFolder) {
49+ shareFolder, useTemp) {
4850 console.log("users:", following)
4951 console.log("channels:", channelSubscriptions)
5052 pull(
5153 sbot.createLogStream({ live: true, reverse: true, limit: 10000 }),
@@ -57,13 +59,14 @@
5759 typeof msg.value.content.text == "string" &&
5860 msg.value.content.text.indexOf("dat://") != -1)
5961 }),
6062 pull.collect((err, logs) => self.extractLinksAndSeed(err, logs,
61- shareFolder))
63+ shareFolder,
64+ useTemp))
6265 )
6366 },
6467
65- getFromPeopleIFollow: function(sbot, shareFolder) {
68+ getFromPeopleIFollow: function(sbot, shareFolder, useTemp) {
6669 var following = []
6770 var channelSubscriptions = []
6871
6972 console.log("Looking for dat links in people i follow")
@@ -96,9 +99,9 @@
9699 })
97100
98101 self.messagesFromPeopleIFollow(sbot, following,
99102 channelSubscriptions,
100- shareFolder)
103+ shareFolder, useTemp)
101104 })
102105 )
103106 })
104107 }
package.jsonView
@@ -1,7 +1,7 @@
11 {
22 "name": "ssb-dat-autoshare",
3- "version": "0.0.1",
3+ "version": "0.0.2",
44 "description": "A cli for auto sharing dat links scuttlebot feeds",
55 "main": "export-data.js",
66 "scripts": {
77 "test": "echo \"Error: no test specified\" && exit 1"

Built with git-ssb-web