Skip to content

Commit

Permalink
Merge back from production and Bump rc version
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl committed Sep 16, 2024
2 parents 72e3963 + 6485b6c commit 2550a6b
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 50 deletions.
5 changes: 4 additions & 1 deletion app/api/files.v2/FilesHealthCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { FileStorage } from './contracts/FileStorage';
import { URLAttachment } from './model/URLAttachment';

function filterFilesInStorage(files: string[]) {
return files.filter(file => !file.endsWith('activity.log'));
return files.filter(
file =>
!file.includes('/log/') && !file.includes('/segmentation/') && !file.includes('index.html')
);
}

export class FilesHealthCheck {
Expand Down
2 changes: 1 addition & 1 deletion app/api/files.v2/infrastructure/S3FileStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class S3FileStorage implements FileStorage {
const response = await this.s3Client.send(
new ListObjectsV2Command({
Bucket: config.s3.bucket,
Prefix: this.tenant.name,
Prefix: `${this.tenant.name}/`,
ContinuationToken: token,
MaxKeys: config.s3.batchSize,
})
Expand Down
31 changes: 31 additions & 0 deletions app/api/files.v2/infrastructure/specs/S3FileStorage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,37 @@ describe('S3FileStorage', () => {
});

describe('list', () => {
it('should list all s3 keys', async () => {
await s3Client.send(
new PutObjectCommand({
Bucket: 'uwazi-development',
Key: 'test-tenant/documents/document1',
Body: 'body',
})
);

await s3Client.send(
new PutObjectCommand({
Bucket: 'uwazi-development',
Key: 'test-tenant/documents/document2',
Body: 'body',
})
);

await s3Client.send(
new PutObjectCommand({
Bucket: 'uwazi-development',
Key: 'test-tenant-2/documents/document3',
Body: 'body',
})
);

const listedFiles = await s3fileStorage.list();

expect(listedFiles.sort()).toEqual(
['test-tenant/documents/document1', 'test-tenant/documents/document2'].sort()
);
});
it('should list all s3 keys', async () => {
await s3Client.send(
new PutObjectCommand({
Expand Down
45 changes: 42 additions & 3 deletions app/api/files.v2/specs/FilesHealthCheck.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,53 @@ describe('FilesHealthCheck', () => {
});
});

it('should ignore activity.log files', async () => {
testStorageFiles = ['log/1-activity.log', 'log/2-activity.log', 'document/file1'];
it('should ignore all /log files', async () => {
testStorageFiles = [
'/log/1-activity.log',
'/log/log.log',
'/log/error.log',
'/log/debug.log',
'/document/file1',
];
await testingEnvironment.setUp({ files: [] });

const summary = await filesHealthCheck.execute();

expect(summary).toMatchObject({
missingInDbList: ['document/file1'],
missingInDbList: ['/document/file1'],
missingInDb: 1,
});
});

it('should ignore all /segmentation files', async () => {
testStorageFiles = [
'/segmentation/1-activity.log',
'/documents/segmentation/1-activity.log',
'/document/file1',
];
await testingEnvironment.setUp({ files: [] });

const summary = await filesHealthCheck.execute();

expect(summary).toMatchObject({
missingInDbList: ['/document/file1'],
missingInDb: 1,
});
});

it('should ignore all index.html files', async () => {
testStorageFiles = [
'/documents/index.html',
'/index.html',
'/segmentation/index.html',
'/document/file1',
];
await testingEnvironment.setUp({ files: [] });

const summary = await filesHealthCheck.execute();

expect(summary).toMatchObject({
missingInDbList: ['/document/file1'],
missingInDb: 1,
});
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uwazi",
"version": "1.185.0-rc1",
"version": "1.185.0-rc2",
"description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.",
"keywords": [
"react"
Expand Down
Loading

0 comments on commit 2550a6b

Please sign in to comment.