mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
Merge pull request #21322 from overleaf/jpa-skip-converted-cleanup
[filestore] remove unnecessary cleanup of converted files GitOrigin-RevId: a46aaee473938209dc56d9fea90f96d09952ce47
This commit is contained in:
parent
29381cf054
commit
52edad6f12
2 changed files with 34 additions and 31 deletions
|
@ -49,9 +49,6 @@ async function insertFile(bucket, key, stream) {
|
||||||
convertedKey,
|
convertedKey,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (Settings.enableConversions) {
|
|
||||||
await PersistorManager.deleteDirectory(bucket, convertedKey)
|
|
||||||
}
|
|
||||||
await PersistorManager.sendStream(bucket, key, stream)
|
await PersistorManager.sendStream(bucket, key, stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +62,10 @@ async function deleteFile(bucket, key) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const jobs = [PersistorManager.deleteObject(bucket, key)]
|
const jobs = [PersistorManager.deleteObject(bucket, key)]
|
||||||
if (Settings.enableConversions) {
|
if (
|
||||||
|
Settings.enableConversions &&
|
||||||
|
bucket === Settings.filestore.stores.template_files
|
||||||
|
) {
|
||||||
jobs.push(PersistorManager.deleteDirectory(bucket, convertedKey))
|
jobs.push(PersistorManager.deleteDirectory(bucket, convertedKey))
|
||||||
}
|
}
|
||||||
await Promise.all(jobs)
|
await Promise.all(jobs)
|
||||||
|
|
|
@ -67,7 +67,11 @@ describe('FileHandler', function () {
|
||||||
compressPng: sinon.stub().resolves(),
|
compressPng: sinon.stub().resolves(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
Settings = {}
|
Settings = {
|
||||||
|
filestore: {
|
||||||
|
stores: { template_files: 'template_files', user_files: 'user_files' },
|
||||||
|
},
|
||||||
|
}
|
||||||
fs = {
|
fs = {
|
||||||
createReadStream: sinon.stub().returns(readStream),
|
createReadStream: sinon.stub().returns(readStream),
|
||||||
}
|
}
|
||||||
|
@ -133,23 +137,6 @@ describe('FileHandler', function () {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('when conversions are enabled', function () {
|
|
||||||
beforeEach(function () {
|
|
||||||
Settings.enableConversions = true
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should delete the convertedKey folder', function (done) {
|
|
||||||
FileHandler.insertFile(bucket, key, stream, err => {
|
|
||||||
expect(err).not.to.exist
|
|
||||||
expect(PersistorManager.deleteDirectory).to.have.been.calledWith(
|
|
||||||
bucket,
|
|
||||||
convertedFolderKey
|
|
||||||
)
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('deleteFile', function () {
|
describe('deleteFile', function () {
|
||||||
|
@ -195,15 +182,31 @@ describe('FileHandler', function () {
|
||||||
Settings.enableConversions = true
|
Settings.enableConversions = true
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should delete the convertedKey folder', function (done) {
|
it('should delete the convertedKey folder for template files', function (done) {
|
||||||
FileHandler.deleteFile(bucket, key, err => {
|
FileHandler.deleteFile(
|
||||||
expect(err).not.to.exist
|
Settings.filestore.stores.template_files,
|
||||||
expect(PersistorManager.deleteDirectory).to.have.been.calledWith(
|
key,
|
||||||
bucket,
|
err => {
|
||||||
convertedFolderKey
|
expect(err).not.to.exist
|
||||||
)
|
expect(PersistorManager.deleteDirectory).to.have.been.calledWith(
|
||||||
done()
|
Settings.filestore.stores.template_files,
|
||||||
})
|
convertedFolderKey
|
||||||
|
)
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should not delete the convertedKey folder for user files', function (done) {
|
||||||
|
FileHandler.deleteFile(
|
||||||
|
Settings.filestore.stores.user_files,
|
||||||
|
key,
|
||||||
|
err => {
|
||||||
|
expect(err).not.to.exist
|
||||||
|
expect(PersistorManager.deleteDirectory).to.not.have.been.called
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue