From e3765ff06cd0296a53774a579a73f31fbfb8450a Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 11:25:14 +1100 Subject: [PATCH 1/3] fix: GridFS file storage breaks on alpha --- src/Adapters/Files/GridFSBucketAdapter.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Adapters/Files/GridFSBucketAdapter.js b/src/Adapters/Files/GridFSBucketAdapter.js index f2b9c48fadd..451165789d7 100644 --- a/src/Adapters/Files/GridFSBucketAdapter.js +++ b/src/Adapters/Files/GridFSBucketAdapter.js @@ -34,7 +34,11 @@ export class GridFSBucketAdapter extends FilesAdapter { useNewUrlParser: true, useUnifiedTopology: true, }; - this._mongoOptions = Object.assign(defaultMongoOptions, mongoOptions); + const _mongoOptions = Object.assign(defaultMongoOptions, mongoOptions); + for (const key of ['enableSchemaHooks', 'schemaCacheTtl', 'maxTimeMS']) { + delete _mongoOptions[key]; + } + this._mongoOptions = _mongoOptions; } _connect() { From 0fd0c13d7cb6847a38dfc366fb084af8fcd9d7e9 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 12:39:28 +1100 Subject: [PATCH 2/3] Update FilesController.spec.js --- spec/FilesController.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/FilesController.spec.js b/spec/FilesController.spec.js index 8fee5aca2f8..a16451f3ef2 100644 --- a/spec/FilesController.spec.js +++ b/spec/FilesController.spec.js @@ -55,6 +55,8 @@ describe('FilesController', () => { const config = Config.get(Parse.applicationId); expect(config.database.adapter._mongoOptions.retryWrites).toBeTrue(); expect(config.filesController.adapter._mongoOptions.retryWrites).toBeTrue(); + expect(config.filesController.adapter._mongoOptions.enableSchemaHooks).toBeUndefined(); + expect(config.filesController.adapter._mongoOptions.schemaCacheTtl).toBeUndefined(); }); it('should create a server log on failure', done => { From db0cf6777697f7e85968131b177520c626b34187 Mon Sep 17 00:00:00 2001 From: dblythy Date: Fri, 19 May 2023 15:01:58 +1000 Subject: [PATCH 3/3] Update GridFSBucketStorageAdapter.spec.js --- spec/GridFSBucketStorageAdapter.spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/GridFSBucketStorageAdapter.spec.js b/spec/GridFSBucketStorageAdapter.spec.js index 419bfdb98d8..7e9c84a59e1 100644 --- a/spec/GridFSBucketStorageAdapter.spec.js +++ b/spec/GridFSBucketStorageAdapter.spec.js @@ -20,6 +20,22 @@ describe_only_db('mongo')('GridFSBucket', () => { await db.dropDatabase(); }); + it('should connect to mongo with the supported database options', async () => { + const databaseURI = 'mongodb://localhost:27017/parse'; + const gfsAdapter = new GridFSBucketAdapter(databaseURI, { + retryWrites: true, + // these are not supported by the mongo client + enableSchemaHooks: true, + schemaCacheTtl: 5000, + maxTimeMS: 30000, + }); + + const db = await gfsAdapter._connect(); + const status = await db.admin().serverStatus(); + expect(status.connections.current > 0).toEqual(true); + expect(db.options?.retryWrites).toEqual(true); + }); + it('should save an encrypted file that can only be decrypted by a GridFS adapter with the encryptionKey', async () => { const unencryptedAdapter = new GridFSBucketAdapter(databaseURI); const encryptedAdapter = new GridFSBucketAdapter(