From e01da69221b39580d1592cc89cbf3634de24f63a Mon Sep 17 00:00:00 2001 From: "Grigorii K. Shartsev" Date: Thu, 8 Oct 2026 18:43:01 +0200 Subject: [PATCH] fix(files): edited files marked locked in files list after close Signed-off-by: Grigorii K. Shartsev --- src/components/Editor.vue | 11 +++++++++++ src/services/SyncService.ts | 14 +++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/components/Editor.vue b/src/components/Editor.vue index 6df8a614d49..e7261a88ab2 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -652,6 +652,7 @@ export default defineComponent({ onSave() { if (this.fileNode) { + // Cheap file update for Files app while the editor is still open this.fileNode.mtime = new Date() this.fileNode.size = new Blob([this.serialize()]).size emit('files:node:updated', this.fileNode) @@ -728,6 +729,16 @@ export default defineComponent({ logger.warn('Failed to destroy editor', { error }) } } + + // Update the file in Files with the latest size, mtime, the lock state + if (this.fileNode) { + const updatedNode = await fetchNode(this.fileNode).catch((err) => + logger.warn('Failed to fetch node', { err }), + ) + if (updatedNode) { + emit('files:node:updated', updatedNode) + } + } }, /** diff --git a/src/services/SyncService.ts b/src/services/SyncService.ts index 0194f45f72d..1fa6e30984c 100644 --- a/src/services/SyncService.ts +++ b/src/services/SyncService.ts @@ -342,16 +342,20 @@ class SyncService { async close() { this.backend?.disconnect() - if (this.hasActiveConnection()) { - close(this.connection.value) + + const activeConnection = this.connection.value + + // Clear connection immediately so hasActiveConnection turns false and we can reconnect. + this.connection.value = undefined + this.bus.emit('close') + + if (activeConnection) { + await close(activeConnection) // Log and ignore possible network issues. .catch((e) => { logger.info('Failed to close connection.', { e }) }) } - // Clear connection so hasActiveConnection turns false and we can reconnect. - this.connection.value = undefined - this.bus.emit('close') } }