From 7f09290053c51d2c216b7d95824ea5a2bd46161b Mon Sep 17 00:00:00 2001 From: S Date: Sun, 16 Apr 2017 02:53:00 +0900 Subject: [PATCH 1/7] =?UTF-8?q?Fix:=20=E8=A7=A3=E9=99=A4->=E9=81=A9?= =?UTF-8?q?=E5=BF=9C=E3=81=AE=E9=A0=86=E3=81=8C=E5=BF=85=E3=81=9A=E3=81=97?= =?UTF-8?q?=E3=82=82=E5=AE=88=E3=82=89=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA?= =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20refs=20#27?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/applyMod.coffee | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/core/applyMod.coffee b/src/core/applyMod.coffee index 215c634..72b40e2 100644 --- a/src/core/applyMod.coffee +++ b/src/core/applyMod.coffee @@ -159,21 +159,26 @@ applyMod = (type, mod, callback) -> * @return {Promise} ### applyMods = (addMods, deleteMods, callback) -> + dLen = deleteMods.length + aLen = addMods.length + deleteDeferArray = [] for dmod in deleteMods deleteDeferArray.push(applyMod("delete", dmod, callback)) - addDeferArray = [] - for amod in addMods - addDeferArray.push(applyMod("add", amod, callback)) - dLen = deleteDeferArray.length - aLen = addDeferArray.length - if dLen > 0 and aLen > 0 - return Promise.all(deleteDeferArray).then( -> - return Promise.all(addDeferArray) - ) - else if dLen > 0 - return Promise.all(deleteDeferArray) + if dLen > 0 + if aLen > 0 + return Promise.all(deleteDeferArray).then( -> + addDeferArray = [] + for amod in addMods + addDeferArray.push(applyMod("add", amod, callback)) + return Promise.all(addDeferArray) + ) + else + return Promise.all(deleteDeferArray) else if aLen > 0 + addDeferArray = [] + for amod in addMods + addDeferArray.push(applyMod("add", amod, callback)) return Promise.all(addDeferArray) else return Promise.resolve() From 0ae728e95995f82835d263bfb8ae7dd11993925d Mon Sep 17 00:00:00 2001 From: S Date: Sun, 16 Apr 2017 03:00:10 +0900 Subject: [PATCH 2/7] =?UTF-8?q?Fix:=20=E9=81=A9=E5=BF=9C=E7=B5=82=E4=BA=86?= =?UTF-8?q?=E3=81=AE=E3=82=BF=E3=82=A4=E3=83=9F=E3=83=B3=E3=82=B0=E3=81=8C?= =?UTF-8?q?=E3=81=9A=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B=E3=81=AE=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20close=20#27?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/applyMod.coffee | 51 ++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/src/core/applyMod.coffee b/src/core/applyMod.coffee index 72b40e2..b29674b 100644 --- a/src/core/applyMod.coffee +++ b/src/core/applyMod.coffee @@ -40,19 +40,47 @@ _getFromLocal = (folder, mod) -> ###* * dataイベントから適応する *### -_applyFromData = (outputFolder, entry) -> +_applyFromData = (outputFolder, entry, pathList, cb) -> + pathList.add(entry.path) fstream .Reader(entry.fullPath) .pipe(fstream.Writer(path.join(outputFolder, entry.path))) + .on("err", (err) -> + cb(false, err) + ) + .on("close", -> + cb(true, entry.path) + return + ) return ###* * entryイベントから適応する *### -_applyFromEntry = (outputFolder, entry) -> - entry.pipe(fstream.Writer(path: path.join(outputFolder, entry.path))) +_applyFromEntry = (outputFolder, entry, pathList, cb) -> + pathList.add(entry.path) + entry + .pipe(fstream.Writer(path: path.join(outputFolder, entry.path))) + .on("err", (err) -> + cb(false, err) + ) + .on("close", -> + cb(true, entry.path) + return + ) return +###* + * 終了確認 + *### +_isEnd = (resolve, reject, pathList) -> + return (ok, data) -> + reject(data) unless ok + pathList.delete(data) + if pathList.size is 0 + resolve() + return + ###* * MODを適応します * @param {"add"|"delete"} type 適応するか解除するか @@ -67,6 +95,7 @@ applyMod = (type, mod, callback) -> else outputFolder = TEMP_FOLDER return new Promise( (resolve, reject) -> + pathList = new Set() fs.ensureDirSync(outputFolder) switch type when "add" then folder = "install" @@ -80,14 +109,17 @@ applyMod = (type, mod, callback) -> else reject("Unknown RepoType") + hasFile = false stream .on("data", (entry) -> - _applyFromData(outputFolder, entry) + hasFile = true + _applyFromData(outputFolder, entry, pathList, _isEnd(resolve, reject, pathList)) return ) .on("entry", (entry) -> return if entry.type is "Directory" - _applyFromEntry(outputFolder, entry) + hasFile = true + _applyFromEntry(outputFolder, entry, pathList, _isEnd(resolve, reject, pathList)) return ) .on("error", (err) -> @@ -95,14 +127,13 @@ applyMod = (type, mod, callback) -> return ) .on("end", -> - resolve() - return - ) - .on("close", -> - resolve() + resolve() unless hasFile return ) return + ).catch( (err) -> + console.log err + return ).then( -> return new Promise( (resolve, reject) -> if pathType is "file" From 2078ef1cf0dbf0ab8871296ed392b32e0bc70842 Mon Sep 17 00:00:00 2001 From: S Date: Sun, 16 Apr 2017 03:31:18 +0900 Subject: [PATCH 3/7] =?UTF-8?q?Update:=20=E5=AE=9F=E8=A1=8C=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E3=81=AEmodid=E3=82=92mod=E5=90=8D=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui/js/repo.coffee | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/gui/js/repo.coffee b/src/gui/js/repo.coffee index 01c91c6..0ee8882 100644 --- a/src/gui/js/repo.coffee +++ b/src/gui/js/repo.coffee @@ -76,7 +76,7 @@ Vue.component("mod",