From f4d17f035447fb9ad94826d7ee6d3ae92c9b4e2a Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Mon, 30 May 2022 14:45:03 -0300 Subject: [PATCH] fix error when file deleted quickly after change --- navigator/src/components/DirectoryEntryList.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/navigator/src/components/DirectoryEntryList.vue b/navigator/src/components/DirectoryEntryList.vue index 014ba77..d982c59 100644 --- a/navigator/src/components/DirectoryEntryList.vue +++ b/navigator/src/components/DirectoryEntryList.vue @@ -216,7 +216,7 @@ export default { (message) => notifications.value.constructNotification("Failed to parse file name", message, 'error') ); if (!entry) - return; // temp file deleted too fast + return; // temp file deleted too quickly entries.value = [...entries.value, reactive(entry)].sort(sortCallbackComputed.value); } @@ -224,8 +224,10 @@ export default { const entryName = eventObj.path.replace(props.path, '').replace(/^\//, ''); console.log(eventObj.event, entryName); const entry = entries.value.find(entry => entry.name === entryName); - const [newContent] = await getDirEntryObjects([entryName], props.path); if (entry) { + const [newContent] = await getDirEntryObjects([entryName], props.path); + if (!newContent) + return; // temp file deleted too quickly const attrsChanged = ["name", "owner", "group", "size", "ctime", "mtime", "atime"].map(key => String(entry[key]) !== String(newContent[key])).includes(true); Object.assign(entry, newContent); if (attrsChanged) sortEntries();