Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit 8151451

Browse files
committed
fix dat.json loading warning when there is no dat.json, make loading the size more reliable
1 parent 90c86f3 commit 8151451

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

client/js/pages/archive/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ var ARCHIVE_ERRORS = {
1717
}
1818

1919
const archivePage = (state, prev, send) => {
20-
if (!module.parent) send('archive:getMetadata', {timeout: 60000})
2120
if (state.archive.error) {
22-
if (state.archive.error.message === 'timed out' && state.archive.entries.length) {
21+
if (state.archive.error.message === 'timed out') {
22+
if (!module.parent) send('archive:getMetadata', {timeout: 60000})
23+
}
24+
25+
if (state.archive.error.message === 'timed out' && state.archive.entries.indexOf('dat.json') > -1) {
2326
// we have the entries, but timed out trying to get the dat.json metadata.
2427
state.archive.error = {message: 'Loading dat.json contents…'}
2528
}

server/dats.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Dats.prototype.get = function (key, cb) {
3939
}
4040

4141
Dats.prototype.entries = function (archive, cb) {
42-
var stream = archive.list({live: false, limit: 100})
42+
var stream = archive.list({live: false, limit: 500})
4343
collect(stream, function (err, entries) {
4444
if (err) return cb(err)
4545
cb(null, entries)
@@ -89,7 +89,11 @@ Dats.prototype.metadata = function (archive, opts, cb) {
8989
if (err || cancelled) return done(err, dat)
9090
var filename = 'dat.json'
9191
archive.get(filename, function (err, entry) {
92-
if (err || cancelled) return done(err, dat)
92+
if (err || cancelled) {
93+
archive.content.get(0, function () {
94+
return done(err, dat)
95+
})
96+
}
9397
archive.download(filename, true, function (err) {
9498
if (err || cancelled) return done(err, dat)
9599
var readStream = archive.createFileReadStream(filename)

0 commit comments

Comments
 (0)