mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-22 02:18:27 +00:00
Merge pull request #22219 from overleaf/jpa-handle-missing-hash
[web] gracefully handle missing hash when compiling GitOrigin-RevId: a9b121716319117ead84b7fed9a67098f63fd9a7
This commit is contained in:
parent
d19c5e236f
commit
bb1072a3a4
2 changed files with 23 additions and 6 deletions
|
@ -740,11 +740,19 @@ function _finaliseRequest(projectId, options, project, docs, files) {
|
|||
for (let path in files) {
|
||||
const file = files[path]
|
||||
path = path.replace(/^\//, '') // Remove leading /
|
||||
const { bucket, key } = getBlobLocation(historyId, file.hash)
|
||||
|
||||
const filestoreURL = `${Settings.apis.filestore.url}/project/${project._id}/file/${file._id}`
|
||||
let url = filestoreURL
|
||||
let fallbackURL
|
||||
if (file.hash) {
|
||||
const { bucket, key } = getBlobLocation(historyId, file.hash)
|
||||
url = `${Settings.apis.filestore.url}/bucket/${bucket}/key/${key}`
|
||||
fallbackURL = filestoreURL
|
||||
}
|
||||
resources.push({
|
||||
path,
|
||||
url: `${Settings.apis.filestore.url}/bucket/${bucket}/key/${key}`,
|
||||
fallbackURL: `${Settings.apis.filestore.url}/project/${project._id}/file/${file._id}`,
|
||||
url,
|
||||
fallbackURL,
|
||||
modified: file.created?.getTime(),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -46,6 +46,11 @@ describe('ClsiManager', function () {
|
|||
created: new Date(),
|
||||
hash: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
|
||||
},
|
||||
'/images/no-hash.png': {
|
||||
name: 'no-hash.png',
|
||||
_id: 'mock-file-id-3',
|
||||
created: new Date(),
|
||||
},
|
||||
}
|
||||
this.clsiCookieKey = 'clsiserver'
|
||||
this.clsiServerId = 'clsi-server-id'
|
||||
|
@ -1027,16 +1032,20 @@ function _makeResources(project, docs, files) {
|
|||
})
|
||||
}
|
||||
for (const [path, file] of Object.entries(files)) {
|
||||
let url
|
||||
let url, fallbackURL
|
||||
if (file.hash === GLOBAL_BLOB_HASH) {
|
||||
url = `${FILESTORE_URL}/bucket/global-blobs/key/aa/aa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`
|
||||
} else {
|
||||
fallbackURL = `${FILESTORE_URL}/project/${project._id}/file/${file._id}`
|
||||
} else if (file.hash) {
|
||||
url = `${FILESTORE_URL}/bucket/project-blobs/key/${project.overleaf.history.id}/${file.hash}`
|
||||
fallbackURL = `${FILESTORE_URL}/project/${project._id}/file/${file._id}`
|
||||
} else {
|
||||
url = `${FILESTORE_URL}/project/${project._id}/file/${file._id}`
|
||||
}
|
||||
resources.push({
|
||||
path: path.replace(/^\//, ''),
|
||||
url,
|
||||
fallbackURL: `${FILESTORE_URL}/project/${project._id}/file/${file._id}`,
|
||||
fallbackURL,
|
||||
modified: file.created.getTime(),
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue