Skip to content
This repository was archived by the owner on Jun 3, 2020. It is now read-only.

Commit 7374e3f

Browse files
committed
Add temporary DaemonDatArchive.getInfo() method
1 parent 9ed1c82 commit 7374e3f

5 files changed

Lines changed: 14 additions & 11 deletions

File tree

crawler/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ exports.doCrawl = async function (archive, crawlSource, crawlDataset, crawlDatas
5353
}
5454

5555
// fetch current archive version
56-
var archiveInfo = {}// TODO await dat.library.getDaemon().getArchiveInfo(archive.key)
56+
var archiveInfo = await archive.getInfo()
5757
var version = archiveInfo ? archiveInfo.version : 0
5858

5959
// fetch change log

dat/daemon.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const DAEMON_PORT = 3101
2323
* @prop {function(): Promise<void>} session.close
2424
* @prop {function(): Promise<void>} session.publish
2525
* @prop {function(): Promise<void>} session.unpublish
26+
* @prop {function(): Promise<Object>} getInfo
2627
* @prop {function(string, Object=, Function=): any} readFile
2728
* @prop {function(string, any, Object=, Function=): void} writeFile
2829
* @prop {function(string, Object=, Function=): void} readdir
@@ -108,6 +109,15 @@ exports.createDatArchiveSession = async function (opts) {
108109
}
109110
},
110111

112+
async getInfo () {
113+
// TODO pull from daemon
114+
return {
115+
version: 0,
116+
size: 0,
117+
peers: 0,
118+
networkStats: {}
119+
}
120+
},
111121
stat: (...args) => {
112122
// wrap the callback with a method which fixes the stat object output
113123
var cb = args.pop()

dat/debugging.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ exports.archivesDebugPage = function () {
1717
<tr><td>Content DKey</td><td>${a.content.discoveryKey.toString('hex')}</td></tr>
1818
<tr><td>Meta Key</td><td>${a.key.toString('hex')}</td></tr>
1919
<tr><td>Content Key</td><td>${a.content.key.toString('hex')}</td></tr>
20-
${a.replicationStreams.map((s, i) => `
21-
<tr><td>Peer ${i}</td><td>${s.peerInfo.type} ${s.peerInfo.host}:${s.peerInfo.port}</td></tr>
22-
`).join('')}
2320
</table>
2421
</div>`
2522
}).join('')}

dat/library.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,13 @@ exports.queryArchives = async function queryArchives (query) {
477477
await Promise.all(archiveInfos.map(async (archiveInfo) => {
478478
var archive = getArchive(archiveInfo.key)
479479
if (archive) {
480-
var info = {}//await daemon.getArchiveInfo(archiveInfo.key) TODO
480+
var info = await archive.getInfo()
481481
archiveInfo.isSwarmed = archiveInfo.userSettings.networked
482482
archiveInfo.size = info.size
483483
archiveInfo.peers = info.peers
484-
archiveInfo.peerHistory = info.peerHistory
485484
} else {
486485
archiveInfo.isSwarmed = false
487486
archiveInfo.peers = 0
488-
archiveInfo.peerHistory = []
489487
}
490488
}))
491489
return isArray ? archiveInfos : archiveInfos[0]
@@ -501,7 +499,7 @@ exports.getArchiveInfo = async function getArchiveInfo (key) {
501499
archivesDb.getMeta(key),
502500
archivesDb.getUserSettings(0, key),
503501
archive.pda.readManifest().catch(_ => {}),
504-
{} // TODO daemon.getArchiveInfo(key)
502+
archive.getInfo()
505503
])
506504
manifest = manifest || {}
507505
meta.key = key
@@ -522,8 +520,6 @@ exports.getArchiveInfo = async function getArchiveInfo (key) {
522520
previewMode: userSettings.previewMode
523521
}
524522
meta.peers = archiveInfo.peers
525-
meta.peerInfo = archiveInfo.peerInfo
526-
meta.peerHistory = archiveInfo.peerHistory
527523
meta.networkStats = archiveInfo.networkStats
528524

529525
return meta

web-apis/bg/dat-archive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ module.exports = {
232232
var reverse = opts.reverse === true
233233
var {start, end} = opts
234234
var {archive, checkoutFS, isPreview} = await lookupArchive(this.sender, url, opts)
235-
var archiveInfo = {} // TODO await datLibrary.getDaemon().getArchiveInfo(archive.key)
235+
var archiveInfo = await archive.getInfo()
236236

237237
if (isPreview) {
238238
// dont use the checkout FS in previews, it has no history() api

0 commit comments

Comments
 (0)