Просмотр исходного кода

[history-v1] fix backup deletion for postgres projects (#23466)

* [history-v1] fix backup deletion for postgres projects

* [history-v1] convert historyId to string on assignment

Co-authored-by: Brian Gough <brian.gough@overleaf.com>

---------

Co-authored-by: Brian Gough <brian.gough@overleaf.com>
GitOrigin-RevId: 5e1033972745a9b72606638f56ebf2147406cc39
Jakob Ackermann 1 год назад
Родитель
Сommit
64e8d2b8b3

+ 2 - 1
services/history-v1/storage/lib/backupDeletion.mjs

@@ -51,7 +51,8 @@ async function deleteProjectBackup(projectId) {
     throw new NotReadyToDelete('refusing to delete non-expired project')
   }
 
-  const historyId = deletedProject.deleterData.deletedProjectOverleafHistoryId
+  const historyId =
+    deletedProject.deleterData.deletedProjectOverleafHistoryId?.toString()
   if (!historyId) {
     throw new NotReadyToDelete(
       'refusing to delete project with unknown historyId'

+ 3 - 3
services/history-v1/test/acceptance/js/api/backupDeletion.test.mjs

@@ -50,7 +50,7 @@ async function deleteProject(projectId) {
 }
 
 /**
- * @param {string|ObjectId} historyId
+ * @param {number|ObjectId} historyId
  * @return {Promise<void>}
  */
 async function expectToHaveBackup(historyId) {
@@ -61,7 +61,7 @@ async function expectToHaveBackup(historyId) {
 }
 
 /**
- * @param {string|ObjectId} historyId
+ * @param {number|ObjectId} historyId
  * @return {Promise<void>}
  */
 async function expectToHaveNoBackup(historyId) {
@@ -90,7 +90,7 @@ describe('backupDeletion', function () {
   })
 
   describe('DELETE /project/:projectId', function () {
-    const postgresHistoryId = '1'
+    const postgresHistoryId = 1
     const projectIdPostgres = new ObjectId('000000000000000000000001')
     const projectIdMongoDB = new ObjectId('000000000000000000000002')
     const projectIdNonDeleted = new ObjectId('000000000000000000000003')