🌟Add an option to not delete files from S3 storage (#321)
This commit is contained in:
+8
-2
@@ -11,6 +11,7 @@ export type S3Configuration = {
|
||||
useSSL: boolean;
|
||||
accessKey: string;
|
||||
secretKey: string;
|
||||
disableRemove: boolean;
|
||||
};
|
||||
|
||||
export default class S3ConnectorService implements StorageConnectorAPI {
|
||||
@@ -66,8 +67,13 @@ export default class S3ConnectorService implements StorageConnectorAPI {
|
||||
|
||||
async remove(path: string): Promise<boolean> {
|
||||
try {
|
||||
await this.client.removeObject(this.minioConfiguration.bucket, path);
|
||||
return true;
|
||||
if (this.minioConfiguration.disableRemove) {
|
||||
logger.info(`File ${path} wasn't removed, file removal is disabled in configuration`);
|
||||
return true;
|
||||
} else {
|
||||
await this.client.removeObject(this.minioConfiguration.bucket, path);
|
||||
return true;
|
||||
}
|
||||
} catch (err) {}
|
||||
return false;
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { Stream, Readable } from "stream";
|
||||
import Multistream from "multistream";
|
||||
import { Consumes, logger, TdriveService } from "../../framework";
|
||||
import LocalConnectorService, { LocalConfiguration } from "./connectors/local/service";
|
||||
import S3ConnectorService from "./connectors/S3/service";
|
||||
import S3ConnectorService from "./connectors/S3/s3-service";
|
||||
import StorageAPI, {
|
||||
DeleteOptions,
|
||||
ReadOptions,
|
||||
@@ -47,6 +47,7 @@ export default class StorageService extends TdriveService<StorageAPI> implements
|
||||
useSSL: Boolean(this.configuration.get<boolean>("S3.useSSL")),
|
||||
accessKey: this.configuration.get<string>("S3.accessKey"),
|
||||
secretKey: this.configuration.get<string>("S3.secretKey"),
|
||||
disableRemove: this.configuration.get<boolean>("S3.disableRemove"),
|
||||
});
|
||||
} else {
|
||||
logger.info("Using 'local' connector for storage.");
|
||||
|
||||
Reference in New Issue
Block a user