git ssb

0+

cel / dillo-dat



Commit 6eaa154c139d73b65498f0c9648613df3d23ee44

send status messages

cel committed on 7/15/2017, 7:47:06 PM
Parent: 14c89af8a6ac540abbb7936e49a5e70e4c474a2b

Files changed

dat.dpichanged
dat.dpiView
@@ -98,8 +98,12 @@
9898 DpiReq.prototype.reload = function (url) {
9999 this.socket.end("<cmd='reload_request' url='" + url + "' '>")
100100 }
101101
102 +DpiReq.prototype.sendStatus = function (msg) {
103 + this.socket.write("<cmd='send_status_message' msg='" + msg + "' '>")
104 +}
105 +
102106 DpiReq.prototype.writeHeader = function (type) {
103107 this.socket.write("<cmd='start_send_page' url='" + this.url + "' '>")
104108 this.socket.write('Content-type: ' + type + '\r\n\r\n')
105109 }
@@ -273,14 +277,16 @@
273277 DpiReq.prototype.serveDashboard = function () {
274278 var self = this
275279 var q = self.urlp.query
276280 if (q.unswarm) {
281 + self.sendStatus('unswarming ' + q.key)
277282 return unswarm(q.key, function (err) {
278283 if (err) return self.serveError(err)
279284 return self.reload(q.reload)
280285 })
281286 }
282287 if (q.restart) {
288 + self.sendStatus('restarting')
283289 self.reload(q.reload)
284290 return process.exit(0)
285291 }
286292
@@ -328,17 +334,20 @@
328334 DpiReq.prototype.serveDat = function () {
329335 var self = this
330336 self.urlp = parseDatUrl(self.url, true)
331337 if (!self.urlp.host) return self.serveError('Archive not found')
338 + self.sendStatus('resolving name')
332339 datDns.resolveName(self.urlp.host, {ignoreCachedMiss: true}, function (err, key) {
333340 if (err) return self.serveError(err)
334341 if (!key) return cb(new TypeError('resolve failed'))
342 + self.sendStatus('getting archive')
335343 withTimeout(getArchive, 10000)(key, function (err, archive) {
336344 if (err) return self.serveError(err)
337345 if (!archive) return self.serveTimedout(self.urlp)
338346 try { if (self.urlp.version) archive = archive.checkout(+self.urlp.version) }
339347 catch(e) { return self.serveError(err) }
340348 self.archive = archive
349 + self.sendStatus('serving file')
341350 self.serve()
342351 })
343352 })
344353 }

Built with git-ssb-web