更正了extraFile,修正了backendRuntimeContext

This commit is contained in:
Xu Chang 2023-10-10 11:53:39 +08:00
parent c9484c0fa1
commit 22264e63a3
5 changed files with 22 additions and 12 deletions

View File

@ -29,7 +29,8 @@ const triggers = [
},
{
name: '删除extraFile时远端也进行删除',
when: 'before',
when: 'commit',
strict: 'makeSure',
entity: 'extraFile',
action: 'remove',
fn: async ({ operation }, context) => {
@ -58,12 +59,13 @@ const triggers = [
},
filter,
}, {
includedDeleted: true,
dontCollect: true,
});
for (const extraFile of extraFileList) {
const { origin } = extraFile;
const uploader = getCos(origin);
await uploader.checkWhetherSuccess(extraFile, context);
await uploader.removeFile(extraFile, context);
}
return 1;
}

View File

@ -31,7 +31,8 @@ const triggers = [
},
{
name: '删除extraFile时远端也进行删除',
when: 'before',
when: 'commit',
strict: 'makeSure',
entity: 'extraFile',
action: 'remove',
fn: async ({ operation }, context) => {
@ -60,12 +61,13 @@ const triggers = [
},
filter,
}, {
includedDeleted: true,
dontCollect: true,
});
for (const extraFile of extraFileList) {
const { origin } = extraFile;
const uploader = (0, cos_1.getCos)(origin);
await uploader.checkWhetherSuccess(extraFile, context);
await uploader.removeFile(extraFile, context);
}
return 1;
}

View File

@ -156,7 +156,7 @@ export abstract class BackendRuntimeContext<ED extends EntityDict & BaseEntityDi
await this.initializedMark;
}
private async initialize(data?: SerializedData) {
protected async initialize(data?: SerializedData) {
if (data) {
await this.begin();
const closeRootMode = this.openRootMode();
@ -246,11 +246,14 @@ export abstract class BackendRuntimeContext<ED extends EntityDict & BaseEntityDi
this.temporaryUserId = userId;
}
toString() {
if (this.rootMode) {
return JSON.stringify({ rootMode: true });
}
return JSON.stringify({ a: this.application?.id, t: this.token?.id });
protected getSerializedData(): SerializedData {
const data = super.getSerializedData();
return {
...data,
a: this.application?.id,
t: this.token?.id,
rm: this.rootMode,
};
}
isRoot() {

View File

@ -25,6 +25,7 @@ export type AspectDict<
export interface SerializedData extends Fsd {
a?: string;
t?: string;
rm?: boolean;
};
export abstract class FrontendRuntimeContext<

View File

@ -37,7 +37,8 @@ const triggers: Trigger<EntityDict, 'extraFile', BackendRuntimeContext<EntityDic
} as CreateTrigger<EntityDict, 'extraFile', BackendRuntimeContext<EntityDict>>,
{
name: '删除extraFile时远端也进行删除',
when: 'before',
when: 'commit',
strict: 'makeSure',
entity: 'extraFile',
action: 'remove',
fn: async ({ operation }, context) => {
@ -69,13 +70,14 @@ const triggers: Trigger<EntityDict, 'extraFile', BackendRuntimeContext<EntityDic
filter,
},
{
includedDeleted: true,
dontCollect: true,
}
);
for (const extraFile of extraFileList) {
const { origin } = extraFile;
const uploader = getCos(origin!);
await uploader.checkWhetherSuccess(extraFile as EntityDict['extraFile']['OpSchema'], context);
await uploader.removeFile(extraFile as EntityDict['extraFile']['OpSchema'], context);
}
return 1;
}