mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Add timestamp to files in deleted bucket
This commit is contained in:
parent
edf1ce1f7e
commit
58db14456a
4 changed files with 20 additions and 6 deletions
|
@ -184,9 +184,9 @@ async function deleteFile(bucketName, key) {
|
||||||
}
|
}
|
||||||
if (settings.filestore.gcs.deletedBucketSuffix) {
|
if (settings.filestore.gcs.deletedBucketSuffix) {
|
||||||
await file.copy(
|
await file.copy(
|
||||||
storage.bucket(
|
storage
|
||||||
`${bucketName}${settings.filestore.gcs.deletedBucketSuffix}`
|
.bucket(`${bucketName}${settings.filestore.gcs.deletedBucketSuffix}`)
|
||||||
)
|
.file(`${key}-${new Date()}`)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
await file.delete()
|
await file.delete()
|
||||||
|
|
6
services/filestore/package-lock.json
generated
6
services/filestore/package-lock.json
generated
|
@ -5582,6 +5582,12 @@
|
||||||
"readable-stream": "2 || 3"
|
"readable-stream": "2 || 3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"timekeeper": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/timekeeper/-/timekeeper-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-W3AmPTJWZkRwu+iSNxPIsLZ2ByADsOLbbLxe46UJyWj3mlYLlwucKiq+/dPm0l9wTzqoF3/2PH0AGFCebjq23A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"tiny-async-pool": {
|
"tiny-async-pool": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/tiny-async-pool/-/tiny-async-pool-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/tiny-async-pool/-/tiny-async-pool-1.1.0.tgz",
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
"sandboxed-module": "2.0.3",
|
"sandboxed-module": "2.0.3",
|
||||||
"sinon": "7.1.1",
|
"sinon": "7.1.1",
|
||||||
"sinon-chai": "^3.3.0",
|
"sinon-chai": "^3.3.0",
|
||||||
"streamifier": "^0.1.1"
|
"streamifier": "^0.1.1",
|
||||||
|
"timekeeper": "^2.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ const { Storage } = require('@google-cloud/storage')
|
||||||
const streamifier = require('streamifier')
|
const streamifier = require('streamifier')
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
const { ObjectId } = require('mongodb')
|
const { ObjectId } = require('mongodb')
|
||||||
|
const tk = require('timekeeper')
|
||||||
|
|
||||||
const fsWriteFile = promisify(fs.writeFile)
|
const fsWriteFile = promisify(fs.writeFile)
|
||||||
const fsStat = promisify(fs.stat)
|
const fsStat = promisify(fs.stat)
|
||||||
|
@ -388,9 +389,11 @@ describe('Filestore', function() {
|
||||||
|
|
||||||
if (backend === 'GcsPersistor') {
|
if (backend === 'GcsPersistor') {
|
||||||
describe('when deleting a file in GCS', function() {
|
describe('when deleting a file in GCS', function() {
|
||||||
let fileId, fileUrl, content, error
|
let fileId, fileUrl, content, error, date
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
|
date = new Date()
|
||||||
|
tk.freeze(date)
|
||||||
fileId = ObjectId()
|
fileId = ObjectId()
|
||||||
fileUrl = `${filestoreUrl}/project/${projectId}/file/${fileId}`
|
fileUrl = `${filestoreUrl}/project/${projectId}/file/${fileId}`
|
||||||
|
|
||||||
|
@ -409,6 +412,10 @@ describe('Filestore', function() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
tk.reset()
|
||||||
|
})
|
||||||
|
|
||||||
it('should not throw an error', function() {
|
it('should not throw an error', function() {
|
||||||
expect(error).not.to.exist
|
expect(error).not.to.exist
|
||||||
})
|
})
|
||||||
|
@ -417,7 +424,7 @@ describe('Filestore', function() {
|
||||||
await TestHelper.expectPersistorToHaveFile(
|
await TestHelper.expectPersistorToHaveFile(
|
||||||
app.persistor,
|
app.persistor,
|
||||||
`${Settings.filestore.stores.user_files}-deleted`,
|
`${Settings.filestore.stores.user_files}-deleted`,
|
||||||
`${projectId}/${fileId}`,
|
`${projectId}/${fileId}-${date}`,
|
||||||
content
|
content
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue