-
Notifications
You must be signed in to change notification settings - Fork 69
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..otherwise, NIIIICE!
const fs = require('fs') | ||
|
||
const argv = minimist(remoteProcess.argv.slice(2)) | ||
const rootDir = argv.data || `${app.getPath('downloads')}/dat` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add this back? this is required so you can run two instances of dat-desktop on the same machine, to verify they're able to replicate with each other properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah sounds good - we should probably come up with a better way to handle options later, but re-adding ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the mkdirSync
is missing still. why not just add back this file as a whole?
models/repos.js
Outdated
var dblocation = path.join(process.env.HOME) | ||
var dbfile = path.join(dblocation, '.dat-desktop-db.json') | ||
|
||
var arr = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this variable name is a bit generic, can we change this to waterfall([fun...
or var tasks
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah, I like tasks!
models/repos.js
Outdated
}), 1500, true) | ||
// boot multidat, create the ~/Downloads/dat directory | ||
function startMultidat (send, done) { | ||
var dblocation = path.join(process.env.HOME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be camelCased, to be consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aye
models/repos.js
Outdated
function (next) { | ||
mkdirp(dblocation, next) | ||
}, | ||
function (val, next) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're not using val
, can you rename it to _
?
also the val
below would be more clear when renamed to multidat
, as that's the identifier used below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup!
models/repos.js
Outdated
function removeDat (state, data, send, done) { | ||
assert.ok(data.key, 'repos-model.deleteDat: data.key should exist') | ||
|
||
if (data.confirmed === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the case where data.confirmed === false
always happens first, can we list it first here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah, nice one (:
} | ||
|
||
function cloneDat (state, data, send, done) { | ||
assert.ok(Buffer.isBuffer(data) || typeof data === 'string', 'repos-model.cloneDat: data should be a buffer or a string') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is taken care of by dat-encoding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not necessarily - if undefined
is passed for example we'll get a weird error somewhere down in a package - this guards against that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(hope you ok with this? - I know I use assert a lot, but feel we're still at a spot where we regularly get weird errors that having lots of asserts can help us catch and trace bugs better)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dat-encoding
has sufficient guards now too, see https://github.com/juliangruber/dat-encoding/blob/master/index.js, but i'm also ok with leaving this here, for extra clarity
function cloneDat (state, data, send, done) { | ||
assert.ok(Buffer.isBuffer(data) || typeof data === 'string', 'repos-model.cloneDat: data should be a buffer or a string') | ||
|
||
var key = encoding.decode(data).toString('hex') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be refactored to var key = encoding.toStr(data)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh nice!
@@ -7,45 +7,37 @@ | |||
"description": "Dat Desktop App", | |||
"author": "Dat Team", | |||
"dependencies": { | |||
"aliasify": "^2.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for cleaning this up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:D
@juliangruber doneeeeee ✨ |
models/repos.js
Outdated
@@ -195,6 +195,14 @@ function createManager (multidat, onupdate) { | |||
var stats = dat.trackStats() | |||
dat.stats = stats | |||
|
|||
multidat.readManifest(dat, function (_, manifest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this fn is only called once, however the metadata should update whenever the dat.json
changes
c7e8631
to
aa9e16f
Compare
@@ -196,12 +194,15 @@ function tableElement (dats, send) { | |||
// ([obj], fn) -> html | |||
function createTable (dats, send) { | |||
return dats.map(dat => { | |||
const progress = dat.stats.blocksTotal | |||
? Math.round(dat.stats.blocksProgress / dat.stats.blocksTotal * 100) | |||
const stats = dat.stats && dat.stats.get() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't dat.stats
always be set? also, this getter was more convenient to use: https://github.com/datproject/dat-desktop/pull/198/files#diff-66caf64acff533dbfc525b13489309cdL178
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a fan of getters / setters / proxies as an API b/c it hides what's going on; but yeah think you're right - it's set always now; was being somewhat defensive (:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, there's a balance with defensive programming and it's not easy to determine. however since we know there's always dat.stats
, it's clearer this way. Otherwise you can read the code above and think otherwise.
Not programming defensively also speaks.
const progress = dat.stats.blocksTotal | ||
? Math.round(dat.stats.blocksProgress / dat.stats.blocksTotal * 100) | ||
const stats = dat.stats && dat.stats.get() | ||
const progress = (stats) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you adding parens around single values? precedence over the identity is always true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const progress = stats
looks like an assignment without parens imo; always write my ternaries / arrow functions with parens; helps with readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const progress = (stats)
can be an assignment too though :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My main point with style is just that it should be consistent over the whole project. Either stick to the existing style, or make the rest of the code base follow along in an atomic step.
const fs = require('fs') | ||
|
||
const argv = minimist(remoteProcess.argv.slice(2)) | ||
const rootDir = argv.data || `${app.getPath('downloads')}/dat` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the mkdirSync
is missing still. why not just add back this file as a whole?
models/repos.js
Outdated
}) | ||
}) | ||
function createModel () { | ||
var manager = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let
models/repos.js
Outdated
|
||
var tasks = [ | ||
function (next) { | ||
mkdirp(dbLocation, next) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process.env.HOME
always exists, no need to mkdirp it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point
models/repos.js
Outdated
mkdirp(dbLocation, next) | ||
}, | ||
function (_, next) { | ||
var db = toilet(dbFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
} | ||
|
||
function cloneDat (state, data, send, done) { | ||
assert.ok(Buffer.isBuffer(data) || typeof data === 'string', 'repos-model.cloneDat: data should be a buffer or a string') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dat-encoding
has sufficient guards now too, see https://github.com/juliangruber/dat-encoding/blob/master/index.js, but i'm also ok with leaving this here, for extra clarity
pages/main-delete.js
Outdated
${confirmModal(() => send('repos:deleteConfirm', link))} | ||
${confirmModal(() => send('repos:remove', { | ||
confirmed: true, | ||
key: link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having key
and link
makes this confusing, do you think we can get it to just use one term across the codebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I'm guilty of this too in the CLI.
In my mind key
the 64 character hash (mostly as a buffer), without any other characters. link
is any think that contains a key (or references one), e.g. dat://<key>
, datproject.org/view/<key>
, datproject.org/karissa/more-tweets-more-votes
(which resolves a key via API). Though I mostly refer to all of these as key
in the CLI.
But we should decide on a consistent terminology.
fixup! more stuff fixup! fix bugggssss fixup! finish like most of this stuff fixup! rm unused deps fixup! default progress to 0 setup metadata add @juliangruber's feedback
just arrived at a place with internet so pushed final changes based on comments you made; tried pushing yest but somehow github wouldn't let me. Should be all good now I think - feel free to merge. Big warning on that this might cause all sorts of bugs to pop up b/c we're handling more errors now; if you folks could go ahead and test things that'd be very valuable I reckon. Cheers! |
you force pushed over commits i added to this branch, that's why github didn't let you |
This touches some of the same code as #173. I think once this patch is merged we can move to some of the ergonomics #173 provides (e.g. using getters and the like for state access). This patch should provide us with some robust underpinnings to work on top ✨
changes
level
which preps us for the upcomingSLEEP
release~/.dat-desktop-db.json
usingtoiletdb
model/repos
to be more in line with the dat clidat
management code into multidat library. It's fully tested to make sure it works as expected and relies on multidrive and the latestdat-node
todo
multidat.readManifest()
method to determine author and titlenotes
dat-node
; they're solved now but we'll probably run into more