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

Commit

Permalink
fix issue with archive dir not existing
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Sep 14, 2016
1 parent 8cc9d9a commit 74b4f48
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,28 +137,31 @@ liveStream(db, {
})
}
} else {
const archive = createArchive(Object.assign({ key }, data.value))
archive.open(refresh)
archive.swarm = swarm(archive)
archive.swarm.on('connection', peer => {
refresh()
peer.on('close', () => refresh())
})
archive.on('download', () => refresh())
archive.on('content', () => refresh())
archive.listStream = archive.list({ live: true })
archive.listStream.on('data', entry => {
if (entry.name != 'dat.json') return
collect(archive.createFileReadStream('dat.json'), (err, raw) => {
if (err) return
const json = JSON.parse(raw.toString())
archive.title = json.title
const path = `${root}/${link}`
fs.mkdir(path, () => {
const archive = createArchive(Object.assign({ key }, data.value))
archive.open(refresh)
archive.swarm = swarm(archive)
archive.swarm.on('connection', peer => {
refresh()
peer.on('close', () => refresh())
})
})
archive.progress = 0.5
archive.on('download', () => refresh())
archive.on('content', () => refresh())
archive.listStream = archive.list({ live: true })
archive.listStream.on('data', entry => {
if (entry.name != 'dat.json') return
collect(archive.createFileReadStream('dat.json'), (err, raw) => {
if (err) return
const json = JSON.parse(raw.toString())
archive.title = json.title
refresh()
})
})
archive.progress = 0.5

archives.set(link, archive)
archives.set(link, archive)
})
}
refresh()
})
Expand Down

0 comments on commit 74b4f48

Please sign in to comment.