Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: write equality checker to file store #9786

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/server/fileStorage/FileStoreManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 (
Expand Down
Loading