diff --git a/packages/server/fileStorage/FileStoreManager.ts b/packages/server/fileStorage/FileStoreManager.ts index 35db10931f2..824b5063523 100644 --- a/packages/server/fileStorage/FileStoreManager.ts +++ b/packages/server/fileStorage/FileStoreManager.ts @@ -39,4 +39,9 @@ export default abstract class FileStoreManager { const partialPath = `Organization/${orgId}/template/${filename}.${dotfreeExt}` return this.putUserFile(file, partialPath) } + + async putDebugFile(file: ArrayBufferLike, nameWithExt: string) { + const partialPath = `__debug__/${nameWithExt}` + return this.putUserFile(file, partialPath) + } } diff --git a/packages/server/graphql/private/mutations/checkRethinkPgEquality.ts b/packages/server/graphql/private/mutations/checkRethinkPgEquality.ts index 818af10d9e6..54e4ea2713b 100644 --- a/packages/server/graphql/private/mutations/checkRethinkPgEquality.ts +++ b/packages/server/graphql/private/mutations/checkRethinkPgEquality.ts @@ -1,6 +1,5 @@ -import fs from 'fs' -import path from 'path' import getRethink from '../../../database/rethinkDriver' +import getFileStoreManager from '../../../fileStorage/getFileStoreManager' import getKysely from '../../../postgres/getKysely' import {checkRowCount, checkTableEq} from '../../../postgres/utils/checkEqBase' import { @@ -20,12 +19,10 @@ const handleResult = async ( const resultStr = JSON.stringify(result) if (!writeToFile) return resultStr - const fileName = `${tableName}-${new Date()}` - const fileDir = path.join(process.cwd(), '__rethinkEquality__') - const fileLocation = path.join(fileDir, fileName) - await fs.promises.mkdir(fileDir, {recursive: true}) - await fs.promises.writeFile(fileLocation, resultStr) - return `Result written to ${fileLocation}` + const fileName = `rethinkdbEquality_${tableName}_${new Date().toISOString()}.json` + const manager = getFileStoreManager() + const buffer = Buffer.from(resultStr, 'utf-8') + return manager.putDebugFile(buffer, fileName) } const checkRethinkPgEquality: MutationResolvers['checkRethinkPgEquality'] = async (