mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
fix(core): Prevent object deletion request on no prefix match (#7366)
This commit is contained in:
parent
7b773cc5cc
commit
63e11e4be9
|
@ -149,6 +149,8 @@ export class ObjectStoreService {
|
||||||
async deleteMany(prefix: string) {
|
async deleteMany(prefix: string) {
|
||||||
const objects = await this.list(prefix);
|
const objects = await this.list(prefix);
|
||||||
|
|
||||||
|
if (objects.length === 0) return;
|
||||||
|
|
||||||
const innerXml = objects.map(({ key }) => `<Object><Key>${key}</Key></Object>`).join('\n');
|
const innerXml = objects.map(({ key }) => `<Object><Key>${key}</Key></Object>`).join('\n');
|
||||||
|
|
||||||
const body = ['<Delete>', innerXml, '</Delete>'].join('\n');
|
const body = ['<Delete>', innerXml, '</Delete>'].join('\n');
|
||||||
|
|
|
@ -248,6 +248,14 @@ describe('deleteMany()', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not send a deletion request if no prefix match', async () => {
|
||||||
|
objectStoreService.list = jest.fn().mockResolvedValue([]);
|
||||||
|
|
||||||
|
const result = await objectStoreService.deleteMany('non-matching-prefix');
|
||||||
|
|
||||||
|
expect(result).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
it('should throw an error on request failure', async () => {
|
it('should throw an error on request failure', async () => {
|
||||||
mockAxios.request.mockRejectedValue(mockError);
|
mockAxios.request.mockRejectedValue(mockError);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue