aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/daemon.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/daemon.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/daemon.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/daemon.py b/packages/meshbay-node/src/meshbay_node/daemon.py
index 022553e..46b4ae1 100644
--- a/packages/meshbay-node/src/meshbay_node/daemon.py
+++ b/packages/meshbay-node/src/meshbay_node/daemon.py
@@ -39,7 +39,7 @@ from pathlib import Path
import uvicorn
from meshbay_common import MNP_VERSION
from meshbay_common.background import spawn
-from meshbay_common.paths import fold
+from meshbay_common.paths import fold, long_path
from meshbay_common.protocol import MNP
from meshbay_node import uploads as uploads_mod
@@ -645,8 +645,15 @@ class NodeDaemon(EnrichmentMixin):
log.warning("Invalid revocation token: %s", e)
async def on_connected():
+ # Back from an unlink: the key was linked again and the hub let
+ # this node in, so it is serving once more.
+ if self._state.get("status") == "waiting_for_node_key":
+ self._state["status"] = "running"
await self._sync_blocklist(hub)
+ def on_unlinked():
+ self._state["status"] = "waiting_for_node_key"
+
ws_task = asyncio.create_task(hub.maintain_ws(
on_incoming=on_incoming,
on_revocation=on_revocation,
@@ -654,6 +661,7 @@ class NodeDaemon(EnrichmentMixin):
group_ids=lambda: list((self._state.get("groups_ctx") or {}).keys()),
on_connected=on_connected,
on_blocklist=self._on_blocklist_update,
+ on_unlinked=on_unlinked,
))
self._tasks.append(ws_task)
log.info("Hub WS task started")
@@ -1043,7 +1051,7 @@ class NodeDaemon(EnrichmentMixin):
self._state["status"] = "waiting_for_node_key"
log.warning(
"Node key not linked. Get it from `meshbay-node "
- "status` and paste it in Settings > Link Node on %s "
+ "status` and paste it in Profile > Linked nodes on %s "
"(the desktop client links it automatically). "
"Retrying in %ds...",
self._config.hub.url, self.LINK_WAIT_S,
@@ -1209,8 +1217,8 @@ class NodeDaemon(EnrichmentMixin):
for path in uploads_mod.orphaned_parts(
uploads_mod.find_parts(roots.roots), live, when):
try:
- size = path.stat().st_size
- path.unlink()
+ size = os.stat(long_path(path)).st_size
+ os.unlink(long_path(path))
except OSError as exc:
log.warning("Could not remove abandoned upload %s: %s",
path.name, exc)