From d52b68112fffd54c5f9c5237ce836bdd0623de9b Mon Sep 17 00:00:00 2001 From: rolldone Date: Fri, 24 Sep 2021 19:13:04 +0800 Subject: [PATCH] Improvement - Set condition if extra watch include on download. If get false delete extra watch because, not include on download, delete the extrawatch --- app/devsync_remote/compute/Watcher.ts | 32 ++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/app/devsync_remote/compute/Watcher.ts b/app/devsync_remote/compute/Watcher.ts index e9808d4..549c5c4 100644 --- a/app/devsync_remote/compute/Watcher.ts +++ b/app/devsync_remote/compute/Watcher.ts @@ -56,18 +56,34 @@ const Watcher = BaseModel.extend>({ let key = upath.normalizeSafe(downloads[a]); newDownloads[key] = []; } + - for (var key in complateExtraWatchs) { - for (var key2 in newDownloads) { - if (key2.includes(key)) { - delete newDownloads[key2]; - break; + if(Object.keys(newDownloads).length > 0){ + for (var key in complateExtraWatchs) { + /* Set condition if extra watch include on download */ + let isFoundOnDownload = false; + for (var key2 in newDownloads) { + if (key2.includes(key)) { + isFoundOnDownload = true; + delete newDownloads[key2]; + break; + } + if (key.includes(key2)) { + isFoundOnDownload = true; + delete newDownloads[key2]; + break; + } } - if (key.includes(key2)) { - delete newDownloads[key2]; - break; + /* If get false delete extra watch because */ + /* not include on download */ + if(isFoundOnDownload == false){ + delete complateExtraWatchs[key]; } } + }else{ + /* If there is no extrawatch include on download */ + /* Reset it! */ + complateExtraWatchs = {}; } let theFinalExtraWatchs = Object.assign(newDownloads, complateExtraWatchs);