Skip to content

Commit

Permalink
🐛 修复订阅脚本重复安装的问题 #257
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Feb 26, 2024
1 parent 2288dae commit 57bc6f9
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'npm'

- name: Package with Node
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/packageRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'npm'

- name: Package with Node
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'npm'

- name: Unit Test
Expand Down
4 changes: 2 additions & 2 deletions src/app/service/script/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ export class ScriptManager extends Manager {
source: InstallSource,
subscribeUrl?: string
) {
const info = await fetchScriptInfo(url, "system", false, uuidv4());
const info = await fetchScriptInfo(url, source, false, uuidv4());
const prepareScript = await prepareScriptByCode(info.code, url, info.uuid);
prepareScript.script.subscribeUrl = subscribeUrl;
await this.event.upsertHandler(prepareScript.script, "system");
await this.event.upsertHandler(prepareScript.script, source);
return Promise.resolve(prepareScript.script);
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/app/service/subscribe/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default class SubscribeManager extends Manager {
subscribeId: subscribe.id,
name: subscribe.name,
});
this.subscribeDAO.update(id, { checktime: new Date().getTime() });
await this.subscribeDAO.update(id, { checktime: new Date().getTime() });
try {
const info = await fetchScriptInfo(
subscribe.url,
Expand Down Expand Up @@ -255,12 +255,16 @@ export default class SubscribeManager extends Manager {
});

await Promise.allSettled(result);

await this.subscribeDAO.update(subscribe.id, subscribe);

InfoNotification(
"订阅更新",
`安装了:${notification[0].join(",")}\n删除了:${notification[1].join(
"\n"
)}`
);

logger.info("subscribe update", {
install: notification[0],
update: notification[1],
Expand Down
2 changes: 1 addition & 1 deletion src/pages/options/routes/SubscribeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function SubscribeList() {
onClick={() => {
Message.info({
id: "checkupdate",
content: t("checking_update"),
content: t("checking_for_updates"),
});
subscribeCtrl
.checkUpdate(subscribe.id)
Expand Down
1 change: 1 addition & 0 deletions src/pkg/utils/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export function copyScript(script: Script, old: Script): Script {
export function copySubscribe(sub: Subscribe, old: Subscribe): Subscribe {
const ret = sub;
ret.id = old.id;
ret.scripts = old.scripts;
ret.createtime = old.createtime;
ret.status = old.status;
return ret;
Expand Down

0 comments on commit 57bc6f9

Please sign in to comment.