Skip to content

Commit

Permalink
feat: write equality checker to file store (#9786)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <matt.krick@gmail.com>
  • Loading branch information
mattkrick authored May 29, 2024
1 parent 2243667 commit adcabbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
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

0 comments on commit adcabbc

Please sign in to comment.