Skip to content

Commit

Permalink
fix: register file systems correctly when using duplicate roleArns
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha committed Nov 4, 2024
1 parent af656bf commit a4e3e98
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@basemaps/config": "^7.11.0",
"@basemaps/geo": "^7.11.0",
"@chunkd/fs": "^11.2.0",
"@chunkd/fs-aws": "^11.2.2",
"@chunkd/fs-aws": "^11.3.0",
"@chunkd/middleware": "^11.1.0",
"@cogeotiff/core": "^9.0.3",
"@cotar/core": "^6.0.1",
Expand Down
9 changes: 5 additions & 4 deletions packages/shared/src/file.system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url';

import { S3Client } from '@aws-sdk/client-s3';
import { sha256base58 } from '@basemaps/config';
import { FileSystem, fsa, FsHttp } from '@chunkd/fs';
import { fsa, FsHttp } from '@chunkd/fs';
import { AwsCredentialConfig, AwsS3CredentialProvider, FsAwsS3 } from '@chunkd/fs-aws';
import { SourceCache, SourceChunk } from '@chunkd/middleware';
import type { SourceCallback, SourceRequest } from '@chunkd/source';
Expand Down Expand Up @@ -44,9 +44,10 @@ applyS3MiddleWare(s3Fs);

const credentials = new AwsS3CredentialProvider();

credentials.onFileSystemCreated = (acc: AwsCredentialConfig, fs: FileSystem): void => {
LogConfig.get().info({ prefix: acc.prefix, roleArn: acc.roleArn }, 'FileSystem:Register');
applyS3MiddleWare(fs as FsAwsS3);
credentials.onFileSystemFound = (acc: AwsCredentialConfig, fs?: FsAwsS3, path?: URL): void => {
if (fs == null) return;
LogConfig.get().info({ prefix: acc.prefix, roleArn: acc.roleArn, path: path?.href }, 'FileSystem:Register');
applyS3MiddleWare(fs);
fsa.register(acc.prefix, fs);
};

Expand Down

0 comments on commit a4e3e98

Please sign in to comment.