mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 18:15:53 +00:00
requested changes
This commit is contained in:
@@ -1,15 +1,9 @@
|
||||
import { ForbiddenError, subject } from "@casl/ability";
|
||||
|
||||
import {
|
||||
TableName,
|
||||
TSecretSnapshotFolders,
|
||||
TSecretSnapshotSecretsV2,
|
||||
TSecretTagJunctionInsert,
|
||||
TSecretV2TagJunctionInsert
|
||||
} from "@app/db/schemas";
|
||||
import { TableName, TSecretTagJunctionInsert, TSecretV2TagJunctionInsert } from "@app/db/schemas";
|
||||
import { decryptSymmetric128BitHexKeyUTF8 } from "@app/lib/crypto";
|
||||
import { InternalServerError, NotFoundError } from "@app/lib/errors";
|
||||
import { chunkArray, groupBy } from "@app/lib/fn";
|
||||
import { groupBy } from "@app/lib/fn";
|
||||
import { logger } from "@app/lib/logger";
|
||||
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
|
||||
import { KmsDataKey } from "@app/services/kms/kms-types";
|
||||
@@ -247,36 +241,23 @@ export const secretSnapshotServiceFactory = ({
|
||||
tx
|
||||
);
|
||||
|
||||
const chunkedSnapshotSecrets = chunkArray(secretVersions, 2500);
|
||||
const chunkedSnapshotFolders = chunkArray(folderVersions, 2500);
|
||||
const snapshotSecrets: TSecretSnapshotSecretsV2[] = [];
|
||||
const snapshotFolders: TSecretSnapshotFolders[] = [];
|
||||
const snapshotSecrets = await snapshotSecretV2BridgeDAL.batchInsert(
|
||||
secretVersions.map(({ id }) => ({
|
||||
secretVersionId: id,
|
||||
envId: folder.environment.envId,
|
||||
snapshotId: newSnapshot.id
|
||||
})),
|
||||
tx
|
||||
);
|
||||
|
||||
for await (const chunk of chunkedSnapshotSecrets) {
|
||||
const result = await snapshotSecretV2BridgeDAL.insertMany(
|
||||
chunk.map(({ id }) => ({
|
||||
secretVersionId: id,
|
||||
envId: folder.environment.envId,
|
||||
snapshotId: newSnapshot.id
|
||||
})),
|
||||
tx
|
||||
);
|
||||
|
||||
snapshotSecrets.push(...result);
|
||||
}
|
||||
|
||||
for await (const chunk of chunkedSnapshotFolders) {
|
||||
const result = await snapshotFolderDAL.insertMany(
|
||||
chunk.map(({ id }) => ({
|
||||
folderVersionId: id,
|
||||
envId: folder.environment.envId,
|
||||
snapshotId: newSnapshot.id
|
||||
})),
|
||||
tx
|
||||
);
|
||||
|
||||
snapshotFolders.push(...result);
|
||||
}
|
||||
const snapshotFolders = await snapshotFolderDAL.batchInsert(
|
||||
folderVersions.map(({ id }) => ({
|
||||
folderVersionId: id,
|
||||
envId: folder.environment.envId,
|
||||
snapshotId: newSnapshot.id
|
||||
})),
|
||||
tx
|
||||
);
|
||||
|
||||
return { ...newSnapshot, secrets: snapshotSecrets, folder: snapshotFolders };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user