mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
Issue 359 support scaleway (#577)
* Fix support of Scaleway S3 bucket #359 While MinIO and AWS return versionId as strings, other S3 API implementations return versionId as integers. We must carefully convert the versionId as string in order to cover these various behaviors. Also ensure that docStorage is initialized before attempting to calculate the data size in order to avoid an exception. * Add unit tests for MinIOExternalStorage#versions() #359 Introduced some unit tests to : - ensure listObjects is called with the right arguments; - cover the case when a S3 bucket implementation does not return the versionId as a string but rather as an integer (like Scaleway): in such a case, ensure that the returned snapshotId is a string; - cover the case when the listObjects function emits an error, ensure the versions() call rejets with the error emitted; - that the deleteMarkers are only returned when the includeDeleteMarkers is passed; --------- Co-authored-by: Florent FAYOLLE <florent.fayolle@beta.gouv.fr>
This commit is contained in:
@@ -2134,6 +2134,9 @@ export class ActiveDoc extends EventEmitter {
|
||||
|
||||
private async _checkDataSizeLimitRatio(docSession: OptDocSession | null) {
|
||||
const start = Date.now();
|
||||
if (!this.docStorage.isInitialized()) {
|
||||
return;
|
||||
}
|
||||
const dataSizeBytes = await this._updateDataSize();
|
||||
const timeToMeasure = Date.now() - start;
|
||||
log.rawInfo('Data size from dbstat...', {
|
||||
|
||||
@@ -25,19 +25,21 @@ type MinIOBucketItemStat = minio.BucketItemStat & {
|
||||
* will work with MinIO and other S3-compatible storage.
|
||||
*/
|
||||
export class MinIOExternalStorage implements ExternalStorage {
|
||||
private _s3: MinIOClient;
|
||||
|
||||
// Specify bucket to use, and optionally the max number of keys to request
|
||||
// in any call to listObjectVersions (used for testing)
|
||||
constructor(public bucket: string, public options: {
|
||||
endPoint: string,
|
||||
port?: number,
|
||||
useSSL?: boolean,
|
||||
accessKey: string,
|
||||
secretKey: string,
|
||||
region: string
|
||||
}, private _batchSize?: number) {
|
||||
this._s3 = new minio.Client(options) as MinIOClient;
|
||||
constructor(
|
||||
public bucket: string,
|
||||
public options: {
|
||||
endPoint: string,
|
||||
port?: number,
|
||||
useSSL?: boolean,
|
||||
accessKey: string,
|
||||
secretKey: string,
|
||||
region: string
|
||||
},
|
||||
private _batchSize?: number,
|
||||
private _s3 = new minio.Client(options) as MinIOClient
|
||||
) {
|
||||
}
|
||||
|
||||
public async exists(key: string, snapshotId?: string) {
|
||||
@@ -131,7 +133,10 @@ export class MinIOExternalStorage implements ExternalStorage {
|
||||
(options?.includeDeleteMarkers || !(v as any).isDeleteMarker))
|
||||
.map(v => ({
|
||||
lastModified: v.lastModified.toISOString(),
|
||||
snapshotId: (v as any).versionId!,
|
||||
// Circumvent inconsistency of MinIO API with versionId by casting it to string
|
||||
// PR to MinIO so we don't have to do that anymore:
|
||||
// https://github.com/minio/minio-js/pull/1193
|
||||
snapshotId: String((v as any).versionId!),
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user