[clsi] reduce write traffic to clsi-cache from free users (#32958)

GitOrigin-RevId: c01cc21c3c82f361c7d82843e65bb087b21434ed
This commit is contained in:
Jakob Ackermann
2026-04-21 10:39:35 +02:00
committed by Copybot
parent 98dbb48c59
commit 926d6bccd7
2 changed files with 31 additions and 20 deletions

View File

@@ -115,6 +115,7 @@ function closeCircuitBreaker(url) {
* @param {Record<string, number>} opts.stats
* @param {Record<string, number>} opts.timings
* @param {Record<string, any>} opts.options
* @param {{path:string,method:string}} opts.metricsOpts
* @return {string | undefined}
*/
function notifyCLSICacheAboutBuild({
@@ -127,6 +128,7 @@ function notifyCLSICacheAboutBuild({
stats,
timings,
options,
metricsOpts,
}) {
if (!Settings.apis.clsiCache.enabled) return undefined
if (!OBJECT_ID_REGEX.test(projectId)) return undefined
@@ -192,26 +194,34 @@ function notifyCLSICacheAboutBuild({
})
}
// PDF preview
enqueue(
outputFiles
.filter(
f =>
f.path === 'output.pdf' ||
f.path === 'output.log' ||
f.path === 'output.synctex.gz'
)
.concat(
outputFiles.filter(f => f.path.endsWith('.blg')).slice(0, MAX_BLG_FILES)
)
.map(f => {
const lean = { path: f.path }
if (f.path === 'output.pdf') {
Object.assign(lean, _.pick(f, 'path', 'size', 'contentId', 'ranges'))
}
return lean
})
)
const isUserCompile = !metricsOpts.path
if (!(isUserCompile && compileGroup === 'standard')) {
// PDF preview, skip for free compiles
enqueue(
outputFiles
.filter(
f =>
f.path === 'output.pdf' ||
f.path === 'output.log' ||
f.path === 'output.synctex.gz'
)
.concat(
outputFiles
.filter(f => f.path.endsWith('.blg'))
.slice(0, MAX_BLG_FILES)
)
.map(f => {
const lean = { path: f.path }
if (f.path === 'output.pdf') {
Object.assign(
lean,
_.pick(f, 'path', 'size', 'contentId', 'ranges')
)
}
return lean
})
)
}
// Compile Cache
buildTarball({ projectId, userId, buildId, outputFiles })

View File

@@ -143,6 +143,7 @@ function compile(req, res, next) {
rootResourcePath: request.rootResourcePath,
stopOnFirstError: request.stopOnFirstError,
},
metricsOpts: request.metricsOpts,
})
}