qiniu cos getFileStat针对线上实测修正
This commit is contained in:
parent
f7ea97cfcf
commit
0388ce6291
|
|
@ -38,18 +38,17 @@ export default OakComponent({
|
|||
getEfIds() {
|
||||
const { efPaths } = this.props;
|
||||
const { oakFullpath } = this.state;
|
||||
assert(efPaths);
|
||||
assert(efPaths && efPaths.length > 0);
|
||||
if (oakFullpath) {
|
||||
const ids = efPaths.map(
|
||||
(path) => {
|
||||
const path2 = path ? `${oakFullpath}.${path}` : oakFullpath;
|
||||
const data = this.features.runningTree.getFreshValue(path2);
|
||||
if (data) {
|
||||
assert(data, `efPath为${path}的路径上取不到extraFile数据,请设置正确的相对路径`);
|
||||
return (data as EntityDict['extraFile']['OpSchema'][]).map(
|
||||
ele => ele.id
|
||||
);
|
||||
}
|
||||
}
|
||||
).flat().filter(
|
||||
ele => !!ele
|
||||
) as string[];
|
||||
|
|
@ -59,6 +58,7 @@ export default OakComponent({
|
|||
},
|
||||
async upload() {
|
||||
const ids = this.getEfIds();
|
||||
assert(ids.length > 0);
|
||||
|
||||
const promises: Promise<void>[] = [];
|
||||
ids.forEach(
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ export abstract class BackendRuntimeContext<ED extends EntityDict & BaseEntityDi
|
|||
await this.begin();
|
||||
const closeRootMode = this.openRootMode();
|
||||
try {
|
||||
const { a: appId, t: tokenValue } = data;
|
||||
const { a: appId, t: tokenValue, rm } = data;
|
||||
const promises: Promise<void>[] = [];
|
||||
if (appId) {
|
||||
promises.push(this.setApplication(appId));
|
||||
|
|
@ -172,7 +172,9 @@ export abstract class BackendRuntimeContext<ED extends EntityDict & BaseEntityDi
|
|||
if (promises.length > 0) {
|
||||
await Promise.all(promises);
|
||||
}
|
||||
if (!rm) {
|
||||
closeRootMode();
|
||||
}
|
||||
await this.commit();
|
||||
} catch (err) {
|
||||
closeRootMode();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { QiniuCosConfig } from '../../types/Config';
|
|||
import { QiniuCloudInstance } from 'oak-external-sdk';
|
||||
import { urlSafeBase64Encode } from '../sign';
|
||||
import { OakUploadException } from '../../types/Exception';
|
||||
import { OakExternalException } from 'oak-domain';
|
||||
|
||||
const QiniuSearchUrl = 'https://rs.qiniuapi.com/stat/EncodedEntryURI';
|
||||
|
||||
|
|
@ -120,11 +121,24 @@ export default class Qiniu implements Cos<ED, BRC, FRC> {
|
|||
|
||||
// web环境下访问不了七牛接口,用mockData过
|
||||
const mockData = process.env.OAK_PLATFORM === 'web' ? { fsize: 100 } : undefined;
|
||||
|
||||
try {
|
||||
const result = await (instance as QiniuCloudInstance).getKodoFileStat(extraFile.bucket!, key, mockData);
|
||||
|
||||
const { fsize } = result;
|
||||
return fsize > 0;
|
||||
}
|
||||
catch (err: any) {
|
||||
// 七牛如果文件不存在会抛出status = 612的异常
|
||||
if (err instanceof OakExternalException) {
|
||||
const data = err.data;
|
||||
if (data && data.status === 612) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async removeFile(extraFile: OpSchema, context: BRC) {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ async function checkWhetherSuccess(context: BackendRuntimeContext<EntityDict>, a
|
|||
}
|
||||
}, {});
|
||||
}
|
||||
else {
|
||||
if (failedIds.length > 0) {
|
||||
await context.operate('extraFile', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'update',
|
||||
|
|
|
|||
Loading…
Reference in New Issue