mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-27 09:42:00 +00:00
Merge pull request #8222 from overleaf/jpa-fix-download-no-build-id
[web] download output files without a build id via web GitOrigin-RevId: 97bb994e29eea6c90f9d885335dc93027bc186bd
This commit is contained in:
parent
d9753dcb22
commit
6f95859981
1 changed files with 13 additions and 7 deletions
|
@ -8,8 +8,6 @@ const searchParams = new URLSearchParams(window.location.search)
|
||||||
export function handleOutputFiles(outputFiles, projectId, data) {
|
export function handleOutputFiles(outputFiles, projectId, data) {
|
||||||
const result = {}
|
const result = {}
|
||||||
|
|
||||||
const pdfDownloadDomain = data.pdfDownloadDomain ?? ''
|
|
||||||
|
|
||||||
const outputFile = outputFiles.get('output.pdf')
|
const outputFile = outputFiles.get('output.pdf')
|
||||||
|
|
||||||
if (outputFile) {
|
if (outputFile) {
|
||||||
|
@ -32,7 +30,7 @@ export function handleOutputFiles(outputFiles, projectId, data) {
|
||||||
params.set('enable_pdf_caching', 'true')
|
params.set('enable_pdf_caching', 'true')
|
||||||
}
|
}
|
||||||
|
|
||||||
result.pdfUrl = `${pdfDownloadDomain}${outputFile.url}?${params}`
|
result.pdfUrl = `${buildURL(outputFile, data.pdfDownloadDomain)}?${params}`
|
||||||
|
|
||||||
// build the URL for downloading the PDF
|
// build the URL for downloading the PDF
|
||||||
params.set('popupDownload', 'true') // save PDF download as file
|
params.set('popupDownload', 'true') // save PDF download as file
|
||||||
|
@ -44,8 +42,6 @@ export function handleOutputFiles(outputFiles, projectId, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const handleLogFiles = async (outputFiles, data, signal) => {
|
export const handleLogFiles = async (outputFiles, data, signal) => {
|
||||||
const pdfDownloadDomain = data.pdfDownloadDomain ?? ''
|
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
log: null,
|
log: null,
|
||||||
logEntries: {
|
logEntries: {
|
||||||
|
@ -76,7 +72,7 @@ export const handleLogFiles = async (outputFiles, data, signal) => {
|
||||||
|
|
||||||
if (logFile) {
|
if (logFile) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${pdfDownloadDomain}${logFile.url}`, {
|
const response = await fetch(buildURL(logFile, data.pdfDownloadDomain), {
|
||||||
signal,
|
signal,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -99,7 +95,7 @@ export const handleLogFiles = async (outputFiles, data, signal) => {
|
||||||
|
|
||||||
if (blgFile) {
|
if (blgFile) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${pdfDownloadDomain}${blgFile.url}`, {
|
const response = await fetch(buildURL(blgFile, data.pdfDownloadDomain), {
|
||||||
signal,
|
signal,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -156,6 +152,16 @@ export function buildLogEntryAnnotations(entries, fileTreeManager) {
|
||||||
return logEntryAnnotations
|
return logEntryAnnotations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildURL(file, pdfDownloadDomain) {
|
||||||
|
if (file.build && pdfDownloadDomain) {
|
||||||
|
// Downloads from the compiles domain must include a build id.
|
||||||
|
// The build id is used implicitly for access control.
|
||||||
|
return `${pdfDownloadDomain}${file.url}`
|
||||||
|
}
|
||||||
|
// Go through web instead, which uses mongo for checking project access.
|
||||||
|
return file.url
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeFilePath(path, rootDocDirname) {
|
function normalizeFilePath(path, rootDocDirname) {
|
||||||
path = path.replace(
|
path = path.replace(
|
||||||
/^.*\/compiles\/[0-9a-f]{24}(-[0-9a-f]{24})?\/(\.\/)?/,
|
/^.*\/compiles\/[0-9a-f]{24}(-[0-9a-f]{24})?\/(\.\/)?/,
|
||||||
|
|
Loading…
Reference in a new issue