Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Allow for specification of dat secret storage directory. #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brandonedens
Copy link

No description provided.

@joehand
Copy link
Collaborator

joehand commented Mar 8, 2018

Thanks! I moved the secret keys to an option in the second argument. Can you update this PR to reflect that? Should make it a bit simpler =).

It'd be great to have a test for this as well! Please also make sure you run npm test on your machine and the syntax is all okay.

@joehand joehand requested review from joehand and removed request for joehand March 8, 2018 17:33
@codecov-io
Copy link

codecov-io commented Mar 9, 2018

Codecov Report

Merging #193 into master will decrease coverage by 0.45%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #193      +/-   ##
==========================================
- Coverage   84.86%   84.41%   -0.46%     
==========================================
  Files           7        7              
  Lines         304      308       +4     
==========================================
+ Hits          258      260       +2     
- Misses         46       48       +2
Impacted Files Coverage Δ
index.js 100% <ø> (ø) ⬆️
lib/storage.js 68% <50%> (-3.43%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 20e7353...3a18e96. Read the comment docs.

@brandonedens brandonedens force-pushed the specify-secret-storage-dir branch 2 times, most recently from 128fc84 to 1f97dd9 Compare March 12, 2018 04:02
lib/storage.js Outdated
if (typeof opts.secretDir !== 'undefined') {
fs.statSync(opts.secretDir).isDirectory()
}
return datStore(storage, opts)
}
} catch (e) {
// Does not exist, make dir
try {
fs.mkdirSync(storage)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you either separate these two try/catch out or check which directory errored. For example, if fs.statSync(opts.secretDir).isDirectory() errors, then we'll make the storage directory even if it exists.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep reworked.

lib/storage.js Outdated
if (typeof opts.secretDir !== 'undefined') {
fs.statSync(opts.secretDir).isDirectory()
}
return datStore(storage, opts)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to return this here or can just return it after try/catch? (having trouble reading with the diff..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, reworked. See if that is more what you expect.

@joehand
Copy link
Collaborator

joehand commented Mar 12, 2018

Are the tests passing locally for you? Look like they are hanging on travis but not sure why.

test/download.js Outdated
t.ok(dat.key, 'has key')
t.ok(dat.archive, 'has archive')
t.notOk(dat.writable, 'archive not writable')
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, add t.end() here =)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the other tests for some cleanup tips too.

@@ -62,6 +62,63 @@ test('download: Download with default opts', function (t) {
})
})

test('download: Download with secretDir opt', function (t) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Sorry was not looking closely at this before, we only have a secret directory when you create the Dat (e.g. sharing).

These tests look good otherwise. Can you also just make sure the downSecretDir has a key in it?

@joehand
Copy link
Collaborator

joehand commented Mar 19, 2018

It's a bit easier to review if you just push a new commit rather than squishing all the changes. I forget what I was commenting on last time, so nice to see the diff =)

@joehand
Copy link
Collaborator

joehand commented Mar 19, 2018

Looks good if you can just move that test over to test it on sharing. 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants