Skip to content

Commit

Permalink
chore: leave out irrelevant config
Browse files Browse the repository at this point in the history
  • Loading branch information
BelgianNoise committed Jan 18, 2022
1 parent 0d421b3 commit 862a6f8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/storage/backend/quota/quota-file.json
Expand Up @@ -16,7 +16,7 @@
"@id": "urn:solid-server:default:SizeReporter",
"@type": "FileSizeReporter",
"fileIdentifierMapper": { "@id": "urn:solid-server:default:FileIdentifierMapper" },
"rootFilePath": { "@id": "urn:solid-server:default:variable:rootFilePath" },
"rootFilePath": { "@id": "urn:solid-server:default:variable:rootFilePath" }
},

{
Expand Down
4 changes: 2 additions & 2 deletions src/storage/size-reporter/FileSizeReporter.ts
Expand Up @@ -16,9 +16,9 @@ export class FileSizeReporter implements SizeReporter<string> {
private readonly ignoreFolders: RegExp[];
private readonly rootFilePath: string;

public constructor(fileIdentifierMapper: FileIdentifierMapper, rootFilePath: string, ignoreFolders: string[]) {
public constructor(fileIdentifierMapper: FileIdentifierMapper, rootFilePath: string, ignoreFolders?: string[]) {
this.fileIdentifierMapper = fileIdentifierMapper;
this.ignoreFolders = ignoreFolders.map((folder: string): RegExp => new RegExp(folder, 'u'));
this.ignoreFolders = ignoreFolders ? ignoreFolders.map((folder: string): RegExp => new RegExp(folder, 'u')) : [];
this.rootFilePath = normalizeFilePath(rootFilePath);
}

Expand Down
4 changes: 0 additions & 4 deletions test/integration/config/quota-pod.json
Expand Up @@ -47,10 +47,6 @@
},
"PodQuotaStrategy:_limit_unit": "bytes"
},
{
"@id": "urn:solid-server:default:SizeReporter",
"FileSizeReporter:_ignoreFolders": [ "^/\\.internal$" ]
},
{
"@id": "urn:solid-server:test:Instances",
"@type": "RecordObject",
Expand Down
16 changes: 16 additions & 0 deletions test/unit/storage/size-reporter/FileSizeReporter.test.ts
Expand Up @@ -31,6 +31,22 @@ describe('A FileSizeReporter', (): void => {
await fsPromises.rmdir(fileRoot, { recursive: true });
});

it('should work without the ignoreFolders constructor parameter.', async(): Promise<void> => {
const tempFileSizeReporter = new FileSizeReporter(
mapper,
fileRoot,
);

const testFile = join(fileRoot, './test.txt');
await fsPromises.writeFile(testFile, 'Test file for file size!');

const result = tempFileSizeReporter.getSize({ path: testFile });
await expect(result).resolves.toBeDefined();
expect((await result).amount).toBe((await fsPromises.stat(testFile)).size);

await fsPromises.unlink(testFile);
});

it('should report the right file size.', async(): Promise<void> => {
const testFile = join(fileRoot, './test.txt');
await fsPromises.writeFile(testFile, 'Test file for file size!');
Expand Down

0 comments on commit 862a6f8

Please sign in to comment.