Skip to content

Commit 606ac06

Browse files
committed
🐛 修复同步时脚本错乱
1 parent 72376db commit 606ac06

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/apps/script/controller.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,16 @@ export class ScriptController {
264264
updatetime: new Date().getTime(),
265265
checktime: 0,
266266
};
267-
let old = await this.scriptModel.findByUUID(script.uuid);
268-
if (!old && uuid == undefined) {
267+
let old;
268+
if (uuid != undefined) {
269+
old = await this.scriptModel.findByUUID(uuid);
270+
} else {
269271
old = await this.scriptModel.findByNameAndNamespace(script.name, script.namespace);
272+
if (!old) {
273+
old = await this.scriptModel.findByUUID(script.uuid);
274+
}
270275
}
276+
271277
if (old) {
272278
copyScript(script, old);
273279
} else {

src/apps/script/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export function loadScriptByUrl(url: string): Promise<ScriptUrlInfo | undefined>
9696

9797
export function copyScript(script: Script, old: Script) {
9898
script.id = old.id;
99+
script.uuid = old.uuid;
99100
script.createtime = old.createtime;
100101
script.checktime = old.checktime;
101102
script.lastruntime = old.lastruntime;

0 commit comments

Comments
 (0)