mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-31 21:01:33 +02:00
[filestore] remove user files endpoints (#28125)
* [filestore] remove user files endpoints * [web] remove user files integration for filestore GitOrigin-RevId: 565fa68a659c07420ee6141d0f276b4e4d2972e0
This commit is contained in:
@@ -115,11 +115,6 @@ describe('ProjectDeleter', function () {
|
||||
|
||||
this.ProjectMock = sinon.mock(Project)
|
||||
this.DeletedProjectMock = sinon.mock(DeletedProject)
|
||||
this.FileStoreHandler = {
|
||||
promises: {
|
||||
deleteProject: sinon.stub().resolves(),
|
||||
},
|
||||
}
|
||||
this.Features = {
|
||||
hasFeature: sinon.stub().returns(true),
|
||||
}
|
||||
@@ -143,7 +138,6 @@ describe('ProjectDeleter', function () {
|
||||
'../DocumentUpdater/DocumentUpdaterHandler':
|
||||
this.DocumentUpdaterHandler,
|
||||
'../Tags/TagsHandler': this.TagsHandler,
|
||||
'../FileStore/FileStoreHandler': this.FileStoreHandler,
|
||||
'../Chat/ChatApiHandler': this.ChatApiHandler,
|
||||
'../Collaborators/CollaboratorsHandler': this.CollaboratorsHandler,
|
||||
'../Collaborators/CollaboratorsGetter': this.CollaboratorsGetter,
|
||||
@@ -480,12 +474,6 @@ describe('ProjectDeleter', function () {
|
||||
)
|
||||
})
|
||||
|
||||
it('should destroy the files in filestore', function () {
|
||||
expect(
|
||||
this.FileStoreHandler.promises.deleteProject
|
||||
).to.have.been.calledWith(this.deletedProjects[0].project._id)
|
||||
})
|
||||
|
||||
it('should destroy the chat threads and messages', function () {
|
||||
expect(
|
||||
this.ChatApiHandler.promises.destroyProject
|
||||
@@ -540,11 +528,6 @@ describe('ProjectDeleter', function () {
|
||||
.called
|
||||
})
|
||||
|
||||
it('should not destroy the files in filestore', function () {
|
||||
expect(this.FileStoreHandler.promises.deleteProject).to.not.have.been
|
||||
.called
|
||||
})
|
||||
|
||||
it('should not destroy the chat threads and messages', function () {
|
||||
expect(this.ChatApiHandler.promises.destroyProject).to.not.have.been
|
||||
.called
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('ProjectDuplicator', function () {
|
||||
this.doc1Lines = ['one']
|
||||
this.doc2Lines = ['two']
|
||||
this.file0 = { name: 'file0', _id: 'file0', hash: 'abcde' }
|
||||
this.file1 = { name: 'file1', _id: 'file1' }
|
||||
this.file1 = { name: 'file1', _id: 'file1', hash: 'fffff' }
|
||||
this.file2 = {
|
||||
name: 'file2',
|
||||
_id: 'file2',
|
||||
@@ -105,22 +105,19 @@ describe('ProjectDuplicator', function () {
|
||||
]
|
||||
this.fileEntries = [
|
||||
{
|
||||
createdBlob: false,
|
||||
createdBlob: true,
|
||||
path: this.file0Path,
|
||||
file: this.newFile0,
|
||||
url: this.filestoreUrl,
|
||||
},
|
||||
{
|
||||
createdBlob: false,
|
||||
createdBlob: true,
|
||||
path: this.file1Path,
|
||||
file: this.newFile1,
|
||||
url: this.filestoreUrl,
|
||||
},
|
||||
{
|
||||
createdBlob: true,
|
||||
path: this.file2Path,
|
||||
file: this.newFile2,
|
||||
url: null,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -143,15 +140,10 @@ describe('ProjectDuplicator', function () {
|
||||
updateProjectStructure: sinon.stub().resolves(),
|
||||
},
|
||||
}
|
||||
this.FileStoreHandler = {
|
||||
promises: {
|
||||
copyFile: sinon.stub().resolves(this.filestoreUrl),
|
||||
},
|
||||
}
|
||||
this.HistoryManager = {
|
||||
promises: {
|
||||
copyBlob: sinon.stub().callsFake((historyId, newHistoryId, hash) => {
|
||||
if (hash === 'abcde') {
|
||||
if (hash === '500') {
|
||||
return Promise.reject(new Error('copy blob error'))
|
||||
}
|
||||
return Promise.resolve()
|
||||
@@ -221,9 +213,6 @@ describe('ProjectDuplicator', function () {
|
||||
flushProjectToTpds: sinon.stub().resolves(),
|
||||
},
|
||||
}
|
||||
this.Features = {
|
||||
hasFeature: sinon.stub().withArgs('project-history-blobs').returns(true),
|
||||
}
|
||||
|
||||
this.ProjectDuplicator = SandboxedModule.require(MODULE_PATH, {
|
||||
requires: {
|
||||
@@ -232,7 +221,6 @@ describe('ProjectDuplicator', function () {
|
||||
'../Docstore/DocstoreManager': this.DocstoreManager,
|
||||
'../DocumentUpdater/DocumentUpdaterHandler':
|
||||
this.DocumentUpdaterHandler,
|
||||
'../FileStore/FileStoreHandler': this.FileStoreHandler,
|
||||
'./ProjectCreationHandler': this.ProjectCreationHandler,
|
||||
'./ProjectDeleter': this.ProjectDeleter,
|
||||
'./ProjectEntityMongoUpdateHandler':
|
||||
@@ -244,7 +232,6 @@ describe('ProjectDuplicator', function () {
|
||||
'../ThirdPartyDataStore/TpdsProjectFlusher': this.TpdsProjectFlusher,
|
||||
'../Tags/TagsHandler': this.TagsHandler,
|
||||
'../History/HistoryManager': this.HistoryManager,
|
||||
'../../infrastructure/Features': this.Features,
|
||||
'../Compile/ClsiCacheManager': {
|
||||
prepareClsiCache: sinon.stub().rejects(new Error('ignore this')),
|
||||
},
|
||||
@@ -281,7 +268,7 @@ describe('ProjectDuplicator', function () {
|
||||
})
|
||||
|
||||
it('should duplicate the files with hashes by copying the blobs in history v1', function () {
|
||||
for (const file of [this.file0, this.file2]) {
|
||||
for (const file of [this.file0, this.file1, this.file2]) {
|
||||
this.HistoryManager.promises.copyBlob.should.have.been.calledWith(
|
||||
this.project.overleaf.history.id,
|
||||
this.newProject.overleaf.history.id,
|
||||
@@ -290,46 +277,6 @@ describe('ProjectDuplicator', function () {
|
||||
}
|
||||
})
|
||||
|
||||
it('should ignore any errors when copying the blobs in history v1', async function () {
|
||||
await expect(
|
||||
this.HistoryManager.promises.copyBlob(
|
||||
this.project.overleaf.history.id,
|
||||
this.newProject.overleaf.history.id,
|
||||
this.file0.hash
|
||||
)
|
||||
).to.be.rejectedWith('copy blob error')
|
||||
})
|
||||
|
||||
it('should not try to copy the blobs for any files without hashes', function () {
|
||||
for (const file of [this.file1]) {
|
||||
this.HistoryManager.promises.copyBlob.should.not.have.been.calledWith(
|
||||
this.project.overleaf.history.id,
|
||||
this.newProject.overleaf.history.id,
|
||||
file.hash
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it('should copy files to the filestore', function () {
|
||||
for (const file of [this.file0, this.file1]) {
|
||||
this.FileStoreHandler.promises.copyFile.should.have.been.calledWith(
|
||||
this.project._id,
|
||||
file._id,
|
||||
this.newProject._id,
|
||||
this.newFileId
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it('should not copy files that have been sent to history-v1 to the filestore', function () {
|
||||
this.FileStoreHandler.promises.copyFile.should.not.have.been.calledWith(
|
||||
this.project._id,
|
||||
this.file2._id,
|
||||
this.newProject._id,
|
||||
this.newFileId
|
||||
)
|
||||
})
|
||||
|
||||
it('should create a blank project', function () {
|
||||
this.ProjectCreationHandler.promises.createBlankProject.should.have.been.calledWith(
|
||||
this.owner._id,
|
||||
@@ -421,6 +368,19 @@ describe('ProjectDuplicator', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when cloning in history-v1 fails', function () {
|
||||
it('should fail the clone operation', async function () {
|
||||
this.file0.hash = '500'
|
||||
await expect(
|
||||
this.ProjectDuplicator.promises.duplicate(
|
||||
this.owner,
|
||||
this.project._id,
|
||||
'name'
|
||||
)
|
||||
).to.be.rejectedWith('copy blob error')
|
||||
})
|
||||
})
|
||||
|
||||
describe('when there is an error', function () {
|
||||
beforeEach(async function () {
|
||||
this.ProjectEntityMongoUpdateHandler.promises.createNewFolderStructure.rejects()
|
||||
|
||||
@@ -26,7 +26,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
},
|
||||
},
|
||||
}
|
||||
this.fileUrl = 'filestore.example.com/file'
|
||||
this.user = { _id: new ObjectId() }
|
||||
|
||||
this.DocModel = class Doc {
|
||||
@@ -152,16 +151,8 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
}
|
||||
this.FileStoreHandler = {
|
||||
promises: {
|
||||
copyFile: sinon.stub(),
|
||||
uploadFileFromDisk: sinon.stub(),
|
||||
deleteFile: sinon.stub(),
|
||||
},
|
||||
|
||||
_buildUrl: sinon
|
||||
.stub()
|
||||
.callsFake(
|
||||
(projectId, fileId) => `www.filestore.test/${projectId}/${fileId}`
|
||||
),
|
||||
}
|
||||
this.FileWriter = {
|
||||
promises: {
|
||||
@@ -670,7 +661,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
linkedFileData: this.linkedFileData,
|
||||
}
|
||||
this.FileStoreHandler.promises.uploadFileFromDisk.resolves({
|
||||
url: this.fileUrl,
|
||||
fileRef: this.newFile,
|
||||
createdBlob: true,
|
||||
})
|
||||
@@ -730,7 +720,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
{
|
||||
file: this.newFile,
|
||||
path: this.path,
|
||||
url: this.fileUrl,
|
||||
createdBlob: true,
|
||||
},
|
||||
]
|
||||
@@ -1069,7 +1058,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
describe('upsertFile', function () {
|
||||
beforeEach(function () {
|
||||
this.FileStoreHandler.promises.uploadFileFromDisk.resolves({
|
||||
url: this.fileUrl,
|
||||
fileRef: this.file,
|
||||
createdBlob: true,
|
||||
})
|
||||
@@ -1181,7 +1169,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
{
|
||||
file: this.newFile,
|
||||
path: this.fileSystemPath,
|
||||
url: this.fileUrl,
|
||||
createdBlob: true,
|
||||
},
|
||||
]
|
||||
@@ -1218,7 +1205,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
element: this.folder,
|
||||
})
|
||||
this.FileStoreHandler.promises.uploadFileFromDisk.resolves({
|
||||
url: this.fileUrl,
|
||||
fileRef: this.newFile,
|
||||
createdBlob: true,
|
||||
})
|
||||
@@ -1254,7 +1240,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
folderId,
|
||||
userId,
|
||||
fileRef: this.newFile,
|
||||
fileStoreUrl: this.fileUrl,
|
||||
source: this.source,
|
||||
createdBlob: true,
|
||||
})
|
||||
@@ -1327,7 +1312,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
folder: this.folder,
|
||||
})
|
||||
|
||||
this.newFileUrl = 'new-file-url'
|
||||
this.newFile = {
|
||||
_id: newFileId,
|
||||
name: 'dummy-upload-filename',
|
||||
@@ -1339,7 +1323,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
overleaf: { history: { id: projectHistoryId } },
|
||||
}
|
||||
this.FileStoreHandler.promises.uploadFileFromDisk.resolves({
|
||||
url: this.newFileUrl,
|
||||
fileRef: this.newFile,
|
||||
createdBlob: true,
|
||||
})
|
||||
@@ -1380,7 +1363,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
{
|
||||
file: this.newFile,
|
||||
path: this.path,
|
||||
url: this.newFileUrl,
|
||||
createdBlob: true,
|
||||
},
|
||||
]
|
||||
@@ -1559,7 +1541,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
this.file = { _id: fileId }
|
||||
this.isNewFile = true
|
||||
this.FileStoreHandler.promises.uploadFileFromDisk.resolves({
|
||||
url: this.fileUrl,
|
||||
fileRef: this.newFile,
|
||||
createdBlob: true,
|
||||
})
|
||||
@@ -1601,7 +1582,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
linkedFileData: this.linkedFileData,
|
||||
userId,
|
||||
fileRef: this.newFile,
|
||||
fileStoreUrl: this.fileUrl,
|
||||
source: this.source,
|
||||
createdBlob: true,
|
||||
}
|
||||
@@ -2567,7 +2547,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
describe('_cleanUpEntity', function () {
|
||||
beforeEach(function () {
|
||||
this.entityId = '4eecaffcbffa66588e000009'
|
||||
this.FileStoreHandler.promises.deleteFile.resolves()
|
||||
this.ProjectEntityUpdateHandler.promises.unsetRootDoc = sinon
|
||||
.stub()
|
||||
.resolves()
|
||||
@@ -2590,12 +2569,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
)
|
||||
})
|
||||
|
||||
it('should not delete the file from FileStoreHandler', function () {
|
||||
this.FileStoreHandler.promises.deleteFile
|
||||
.calledWith(projectId, this.entityId)
|
||||
.should.equal(false)
|
||||
})
|
||||
|
||||
it('should not attempt to delete from the document updater', function () {
|
||||
this.DocumentUpdaterHandler.promises.deleteDoc.called.should.equal(
|
||||
false
|
||||
@@ -2862,7 +2835,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
.resolves({ lines: this.docLines, rev: this.rev })
|
||||
this.FileWriter.promises.writeLinesToDisk.resolves(this.tmpFilePath)
|
||||
this.FileStoreHandler.promises.uploadFileFromDisk.resolves({
|
||||
url: this.fileStoreUrl,
|
||||
fileRef: this.file,
|
||||
createdBlob: true,
|
||||
})
|
||||
@@ -2927,7 +2899,6 @@ describe('ProjectEntityUpdateHandler', function () {
|
||||
{
|
||||
file: this.file,
|
||||
path: this.path,
|
||||
url: this.fileStoreUrl,
|
||||
createdBlob: true,
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user