Skip to content

Commit

Permalink
🐛 修复同步时脚本错乱
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Dec 10, 2021
1 parent 72376db commit 606ac06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/apps/script/controller.ts
Expand Up @@ -264,10 +264,16 @@ export class ScriptController {
updatetime: new Date().getTime(),
checktime: 0,
};
let old = await this.scriptModel.findByUUID(script.uuid);
if (!old && uuid == undefined) {
let old;
if (uuid != undefined) {
old = await this.scriptModel.findByUUID(uuid);
} else {
old = await this.scriptModel.findByNameAndNamespace(script.name, script.namespace);
if (!old) {
old = await this.scriptModel.findByUUID(script.uuid);
}
}

if (old) {
copyScript(script, old);
} else {
Expand Down
1 change: 1 addition & 0 deletions src/apps/script/utils.ts
Expand Up @@ -96,6 +96,7 @@ export function loadScriptByUrl(url: string): Promise<ScriptUrlInfo | undefined>

export function copyScript(script: Script, old: Script) {
script.id = old.id;
script.uuid = old.uuid;
script.createtime = old.createtime;
script.checktime = old.checktime;
script.lastruntime = old.lastruntime;
Expand Down

0 comments on commit 606ac06

Please sign in to comment.