Skip to content

Commit

Permalink
feat(fs.js): Write DDO File to Local Identity Folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Prash74 committed Dec 6, 2019
1 parent 3c4cd03 commit a83820f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { createSwarm } = require('ara-network/discovery')
const { createCFS } = require('cfsnet/create')
const { normalize } = require('./did')
const isDomainName = require('is-domain-name')
const isBrowser = require('is-browser')
const { toHex } = require('./util')
const { DID } = require('did-uri')
const mkdirp = require('mkdirp')
Expand Down Expand Up @@ -196,7 +197,11 @@ async function readFile(identifier, filename, opts) {

async function onjoin(cfs, did, done) {
try {
done(null, await cfs.readFile(filename))
const buffer = await cfs.readFile(filename)
if (false === isBrowser) {
await writeFile(identifier, filename, buffer, opts)
}
done(null, buffer)
} catch (err) {
done(new NoEntityError(filename, 'open'))
}
Expand Down

0 comments on commit a83820f

Please sign in to comment.