mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 14:27:30 +00:00
PIT: fix for folder commit order on cascade deletion
This commit is contained in:
@@ -712,22 +712,6 @@ export const folderCommitServiceFactory = ({
|
|||||||
}));
|
}));
|
||||||
logger.info(`Found ${changes.length} changes for ${folderId}`);
|
logger.info(`Found ${changes.length} changes for ${folderId}`);
|
||||||
|
|
||||||
await Promise.all(
|
|
||||||
changes
|
|
||||||
.filter((change) => change.type === ChangeType.DELETE && change.folderVersionId)
|
|
||||||
.map(async (change) => {
|
|
||||||
await createDeleteCommitForNestedFolders({
|
|
||||||
folderId: change.folderId,
|
|
||||||
actorMetadata,
|
|
||||||
actorType,
|
|
||||||
envId,
|
|
||||||
parentFolderName: folderVersion.name,
|
|
||||||
step: step + 1,
|
|
||||||
tx
|
|
||||||
});
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const newCommit = await folderCommitDAL.create(
|
const newCommit = await folderCommitDAL.create(
|
||||||
{
|
{
|
||||||
actorMetadata,
|
actorMetadata,
|
||||||
@@ -756,6 +740,22 @@ export const folderCommitServiceFactory = ({
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
changes
|
||||||
|
.filter((change) => change.type === ChangeType.DELETE && change.folderVersionId)
|
||||||
|
.map(async (change) => {
|
||||||
|
await createDeleteCommitForNestedFolders({
|
||||||
|
folderId: change.folderId,
|
||||||
|
actorMetadata,
|
||||||
|
actorType,
|
||||||
|
envId,
|
||||||
|
parentFolderName: folderVersion.name,
|
||||||
|
step: step + 1,
|
||||||
|
tx
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -780,21 +780,6 @@ export const folderCommitServiceFactory = ({
|
|||||||
throw new NotFoundError({ message: `Folder with ID ${data.folderId} not found` });
|
throw new NotFoundError({ message: `Folder with ID ${data.folderId} not found` });
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(
|
|
||||||
data.changes.map(async (change) => {
|
|
||||||
if (change.type === ChangeType.DELETE && change.folderId) {
|
|
||||||
await createDeleteCommitForNestedFolders({
|
|
||||||
folderId: change.folderId,
|
|
||||||
actorMetadata: metadata,
|
|
||||||
actorType: data.actor.type,
|
|
||||||
envId: folder.envId,
|
|
||||||
parentFolderName: folder.name,
|
|
||||||
tx
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const newCommit = await folderCommitDAL.create(
|
const newCommit = await folderCommitDAL.create(
|
||||||
{
|
{
|
||||||
actorMetadata: metadata,
|
actorMetadata: metadata,
|
||||||
@@ -824,6 +809,21 @@ export const folderCommitServiceFactory = ({
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
data.changes.map(async (change) => {
|
||||||
|
if (change.type === ChangeType.DELETE && change.folderId) {
|
||||||
|
await createDeleteCommitForNestedFolders({
|
||||||
|
folderId: change.folderId,
|
||||||
|
actorMetadata: metadata,
|
||||||
|
actorType: data.actor.type,
|
||||||
|
envId: folder.envId,
|
||||||
|
parentFolderName: folder.name,
|
||||||
|
tx
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
await createFolderCheckpoint({ folderId: data.folderId, folderCommitId: newCommit.id, tx });
|
await createFolderCheckpoint({ folderId: data.folderId, folderCommitId: newCommit.id, tx });
|
||||||
if (folderCommitQueueService) {
|
if (folderCommitQueueService) {
|
||||||
if (!folder.parentId) {
|
if (!folder.parentId) {
|
||||||
@@ -1640,7 +1640,6 @@ export const folderCommitServiceFactory = ({
|
|||||||
changes: diff,
|
changes: diff,
|
||||||
folderPath: folderPath || ""
|
folderPath: folderPath || ""
|
||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
diff.map(async (change) => {
|
diff.map(async (change) => {
|
||||||
if (change.type === ResourceType.FOLDER && change.changeType === ChangeType.CREATE) {
|
if (change.type === ResourceType.FOLDER && change.changeType === ChangeType.CREATE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user