pinokiod 3.8.94 → 3.8.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,11 +20,11 @@ class Caddy {
20
20
  }
21
21
  }
22
22
  async start() {
23
- let running = await this.running()
24
- console.log("Running", running)
25
- if (running) {
26
- return
27
- }
23
+ // let running = await this.running()
24
+ // console.log("Running", running)
25
+ // if (running) {
26
+ // return
27
+ // }
28
28
  let installed = await this.installed()
29
29
  console.log("Caddy Installed?", installed)
30
30
  if (installed) {
package/kernel/index.js CHANGED
@@ -260,22 +260,34 @@ class Kernel {
260
260
  this.log_queue.push({ data, group, info })
261
261
  }
262
262
  async refresh(notify_peers) {
263
- console.log("kernel.refresh", { notify_peers })
264
- await Promise.all([
265
- // refresh proc info
266
- this.processes.refresh(),
267
- // refresh peer info
268
- this.peer.refresh()
269
- ])
270
- console.log("proc info", this.processes.info)
271
- console.log("peer info", this.peer.info)
272
- // refresh router info
273
- await this.router.refresh()
274
- console.log("router info", this.router.published())
275
-
276
- if (notify_peers) {
277
- // broadcast to peers to refresh
278
- await this.peer.notify_peers()
263
+ let env = await Environment.get(this.homedir)
264
+ let active = false
265
+ // if PINOKIO_NETWORK_SHARE is 0 or false, turn it off
266
+ if (env && env.PINOKIO_NETWORK_ACTIVE && (env.PINOKIO_NETWORK_ACTIVE==="1" || env.PINOKIO_NETWORK_ACTIVE.toLowerCase()==="true")) {
267
+ active = true
268
+ }
269
+
270
+ console.log("kernel.refresh", { active, notify_peers })
271
+ if (active) {
272
+
273
+
274
+ await Promise.all([
275
+ // refresh proc info
276
+ this.processes.refresh(),
277
+ // refresh peer info
278
+ this.peer.refresh()
279
+ ])
280
+ console.log("proc info", this.processes.info)
281
+ console.log("peer info", this.peer.info)
282
+ // refresh router info
283
+ await this.router.refresh()
284
+ console.log("router info", this.router.published())
285
+ await this.peer.refresh()
286
+
287
+ if (notify_peers) {
288
+ // broadcast to peers to refresh
289
+ await this.peer.notify_peers()
290
+ }
279
291
  }
280
292
  }
281
293
  async clearLog(group) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.8.94",
3
+ "version": "3.8.96",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -3164,8 +3164,13 @@ class Server {
3164
3164
  }))
3165
3165
  this.app.get("/du/:name", ex(async (req, res) => {
3166
3166
  let p = this.kernel.path("api", req.params.name)
3167
- let d1 = await Util.du(p)
3168
- res.json({ du: d1 })
3167
+ try {
3168
+ let d1 = await Util.du(p)
3169
+ res.json({ du: d1 })
3170
+ } catch (e) {
3171
+ console.log("disk usage error", e)
3172
+ res.json({ du: 0 })
3173
+ }
3169
3174
  }))
3170
3175
  this.app.get("/edit/*", ex(async (req, res) => {
3171
3176
  let pathComponents = req.params[0].split("/")
@@ -3875,6 +3880,7 @@ class Server {
3875
3880
  if (this.kernel.peer.active) {
3876
3881
  // if network is active, return success only if the router is up for all of its peers (including itself)
3877
3882
  console.log({ peer_info: this.kernel.peer.info })
3883
+ console.time("check_peer")
3878
3884
  let ready = true
3879
3885
  if (this.kernel.peer.info) {
3880
3886
  for(let host in this.kernel.peer.info) {
@@ -3890,6 +3896,7 @@ class Server {
3890
3896
  ready = false;
3891
3897
  }
3892
3898
  console.log({ info: this.kernel.peer.info, ready })
3899
+ console.timeEnd("check_peer")
3893
3900
  if (ready) {
3894
3901
  res.json({ success: true })
3895
3902
  } else {
@@ -1595,22 +1595,24 @@ body.dark .loader-container {
1595
1595
  fetch("/du/<%=name%>").then((res) => {
1596
1596
  return res.json()
1597
1597
  }).then((res) => {
1598
- let val
1599
- //let k = 1024
1600
- let k = 1000
1601
- if (res.du > k * k * k) {
1602
- // GB
1603
- val = `${Math.floor(res.du/k/k/k * 100) / 100} GB`
1604
- } else if (res.du > k * k) {
1605
- // MB
1606
- val = `${Math.floor(res.du/k/k * 100) / 100} MB`
1598
+ if (res.du > 0) {
1599
+ let val
1600
+ //let k = 1024
1601
+ let k = 1000
1602
+ if (res.du > k * k * k) {
1603
+ // GB
1604
+ val = `${Math.floor(res.du/k/k/k * 100) / 100} GB`
1605
+ } else if (res.du > k * k) {
1606
+ // MB
1607
+ val = `${Math.floor(res.du/k/k * 100) / 100} MB`
1608
+ } else {
1609
+ // KB
1610
+ val = `${Math.floor(res.du/k * 100) / 100} KB`
1611
+ }
1612
+ console.log("DU VAL", val)
1613
+ document.querySelector(".disk-usage").innerHTML = val
1607
1614
  } else {
1608
- // KB
1609
- val = `${Math.floor(res.du/k * 100) / 100} KB`
1610
1615
  }
1611
- console.log("DU VAL", val)
1612
- //document.querySelector(".disk-usage").innerHTML = `<i class="fa-regular fa-hard-drive"></i> ${val}`
1613
- document.querySelector(".disk-usage").innerHTML = val
1614
1616
  })
1615
1617
  }
1616
1618
  const refresh = async (silent, options) => {