Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(server): disable checksum check for r2 storage when using aws-s3 sdk (#9735)

liuyi38281448491a
diff --git a/packages/backend/server/scripts/self-host-predeploy.js b/packages/backend/server/scripts/self-host-predeploy.js
index 04cd380826..ba5c43105f 100644
--- a/packages/backend/server/scripts/self-host-predeploy.js
+++ b/packages/backend/server/scripts/self-host-predeploy.js
@@ -8,7 +8,7 @@ const SELF_HOST_CONFIG_DIR = '/root/.affine/config';
function generateConfigFile() {
const content = fs.readFileSync('./dist/config/affine.js', 'utf-8');
return content.replace(
- /(^\/\/#.*$)|(^\/\/\s+TODO.*$)|("use\sstrict";?)|(^.*eslint-disable.*$)/gm,
+ /(^\/\/#.*$)|(^\/\/\s+TODO.*$)|("use\sstrict";?)|(^.*lint-disable.*$)/gm,
''
);
}
diff --git a/packages/backend/server/src/config/affine.self.ts b/packages/backend/server/src/config/affine.self.ts
index 1c8900f9c8..3069ef60c3 100644
--- a/packages/backend/server/src/config/affine.self.ts
+++ b/packages/backend/server/src/config/affine.self.ts
@@ -1,4 +1,4 @@
-/* eslint-disable @typescript-eslint/no-non-null-assertion */
+/* oxlint-disable @typescript-eslint/no-non-null-assertion */
// Custom configurations for AFFiNE Cloud
// ====================================================================================
// Q: WHY THIS FILE EXISTS?
@@ -31,6 +31,8 @@ if (env.R2_OBJECT_STORAGE_ACCOUNT_ID) {
accessKeyId: env.R2_OBJECT_STORAGE_ACCESS_KEY_ID!,
secretAccessKey: env.R2_OBJECT_STORAGE_SECRET_ACCESS_KEY!,
},
+ requestChecksumCalculation: 'WHEN_REQUIRED',
+ responseChecksumValidation: 'WHEN_REQUIRED',
});
AFFiNE.storages.avatar.provider = 'cloudflare-r2';
AFFiNE.storages.avatar.bucket = 'account-avatar';
diff --git a/packages/backend/server/src/config/affine.ts b/packages/backend/server/src/config/affine.ts
index b693473830..c948d6861a 100644
--- a/packages/backend/server/src/config/affine.ts
+++ b/packages/backend/server/src/config/affine.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @typescript-eslint/no-non-null-assertion */
//
// ###############################################################
// ## AFFiNE Configuration System ##
@@ -99,9 +98,14 @@ AFFiNE.server.port = 3010;
// /* AWS S3 Plugin */
// /* Enable if you choose to store workspace blobs or user avatars in AWS S3 Storage Service */
// AFFiNE.use('aws-s3', {
-// credentials: {
-// accessKeyId: '',
-// secretAccessKey: '',
+// credentials: {
+// accessKeyId: '',
+// secretAccessKey: '',
+// },
+// /* Whether enable checksum calculation for request */
+// /* see https://github.com/aws/aws-sdk-js-v3/issues/6810 */
+// requestChecksumCalculation: 'WHEN_REQUIRED',
+// responseChecksumValidation: 'WHEN_REQUIRED',
// })
// /* Update the provider of storages */
// AFFiNE.storages.blob.provider = 'cloudflare-r2';
diff --git a/tools/cli/src/webpack/s3-plugin.ts b/tools/cli/src/webpack/s3-plugin.ts
index 5a6b26adc3..00de2355c6 100644
--- a/tools/cli/src/webpack/s3-plugin.ts
+++ b/tools/cli/src/webpack/s3-plugin.ts
@@ -18,6 +18,8 @@ export class WebpackS3Plugin implements WebpackPluginInstance {
accessKeyId: process.env.R2_ACCESS_KEY_ID!,
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
},
+ requestChecksumCalculation: 'WHEN_REQUIRED',
+ responseChecksumValidation: 'WHEN_REQUIRED',
});
apply(compiler: Compiler) {