From df683425cb914d15780791b1a30abcff963b6623 Mon Sep 17 00:00:00 2001 From: Trevor Fitzgerald Date: Fri, 3 Jan 2025 22:38:40 -0500 Subject: [PATCH 1/2] Only watch for file writes, wip --- src/components/FolderWatcher.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/FolderWatcher.vue b/src/components/FolderWatcher.vue index 1cbba94..e0bba88 100644 --- a/src/components/FolderWatcher.vue +++ b/src/components/FolderWatcher.vue @@ -72,6 +72,11 @@ function stopWatching() { } function handleFolderChange(event: WatchEvent): void { + console.log(event.type, event.paths); + if (event.type.access.mode !== 'write') { + return; + } + if (event.paths.find(filename => isMultiGamePgn(filename))) { status.setRoundHasMultiGamePgn(props.round.round.id); } From 9722e1dc4bbcfab6e80566ab6fb98fc78a6ed5e6 Mon Sep 17 00:00:00 2001 From: Trevor Fitzgerald Date: Sat, 4 Jan 2025 09:39:40 -0500 Subject: [PATCH 2/2] fix conditional --- src/components/FolderWatcher.vue | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/components/FolderWatcher.vue b/src/components/FolderWatcher.vue index e0bba88..909566d 100644 --- a/src/components/FolderWatcher.vue +++ b/src/components/FolderWatcher.vue @@ -72,25 +72,23 @@ function stopWatching() { } function handleFolderChange(event: WatchEvent): void { - console.log(event.type, event.paths); - if (event.type.access.mode !== 'write') { - return; - } - - if (event.paths.find(filename => isMultiGamePgn(filename))) { - status.setRoundHasMultiGamePgn(props.round.round.id); - } + const type = event.type; + if (typeof type !== 'string' && 'access' in type && 'mode' in type.access && type.access.mode === 'write') { + if (event.paths.find(filename => isMultiGamePgn(filename))) { + status.setRoundHasMultiGamePgn(props.round.round.id); + } - const toUpload = multiOrSingleFilter(event.paths); + const toUpload = multiOrSingleFilter(event.paths); - if (toUpload.length === 0) { - return; - } + if (toUpload.length === 0) { + return; + } - add_to_queue(props.round.round.id, toUpload); + add_to_queue(props.round.round.id, toUpload); - const paths = toUpload.map(file => file.split('/').pop()); - logs.info(`Modified: ${paths.join(', ')}`); + const paths = toUpload.map(file => file.split('/').pop()); + logs.info(`Modified: ${paths.join(', ')}`); + } } async function resetAndReupload() {