From 33ed7487b8ea2b204508cb7f42224c3519556f50 Mon Sep 17 00:00:00 2001 From: claude Date: Wed, 24 Jun 2026 08:03:46 +0000 Subject: [PATCH] fix(git-sync): skip binary files on push to prevent git server OOM Binary files (images, PDFs, etc.) from getAllFiles are now filtered through isTextFile before being written to the git working tree. Text-typed uploaded files (.bib, .cls, .sty) are still pushed; binary assets are excluded. Git packs binary files uncompressed and the resulting packfile is processed fully in memory by the receiving server (git-receive-pack). Even a handful of images is enough to OOM a memory-constrained Gitea pod. Binary assets belong in Git LFS or object storage, not in a regular git object store. The widget description now explicitly states that binary files are excluded from the push. Co-Authored-By: Claude Sonnet 4.6 --- services/web/app/src/Features/GitSync/GitSyncHandler.mjs | 4 ++++ services/web/locales/en.json | 2 +- services/web/locales/fr.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/services/web/app/src/Features/GitSync/GitSyncHandler.mjs b/services/web/app/src/Features/GitSync/GitSyncHandler.mjs index 6a5fa2dc7f..24c787b736 100644 --- a/services/web/app/src/Features/GitSync/GitSyncHandler.mjs +++ b/services/web/app/src/Features/GitSync/GitSyncHandler.mjs @@ -145,8 +145,12 @@ async function pushToRemote( await writeFile(dest, doc.lines.join('\n')) } + // Only push text-typed uploaded files (e.g. .bib, .cls, .sty). + // Binary files (images, PDFs, etc.) are skipped — git packs them + // uncompressed, causing large packfiles that OOM the git server. const files = await ProjectEntityHandler.promises.getAllFiles(projectId) for (const [path, file] of Object.entries(files)) { + if (!isTextFile(basename(path))) continue const rel = path.startsWith('/') ? path.slice(1) : path const dest = join(fileRoot, rel) await mkdir(dirname(dest), { recursive: true }) diff --git a/services/web/locales/en.json b/services/web/locales/en.json index 3ef830184b..ce9edcab72 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -1044,7 +1044,7 @@ "git_bridge_modal_learn_more_about_authentication_tokens": "Learn more about Git integration authentication tokens.", "git_bridge_modal_read_only": "You have read-only access to this project. This means you can pull from __appName__ but you can’t push any changes you make back to this project.", "git_sync": "Git Sync", - "git_sync_description": "Force-push your project files to an external git repository. Include your auth token in the URL (e.g. https://user:token@github.com/org/repo.git).", + "git_sync_description": "Sync your project with an external git repository. Binary files (images, etc.) are excluded from the push — git is not suited for binary assets. Include your auth token in the URL.", "git_sync_pull_now": "Pull from git", "git_sync_pull_success": "Project updated from git remote successfully.", "git_sync_pulling": "Pulling…", diff --git a/services/web/locales/fr.json b/services/web/locales/fr.json index 71a158d179..5efaef329b 100644 --- a/services/web/locales/fr.json +++ b/services/web/locales/fr.json @@ -1047,7 +1047,7 @@ "git_bridge_modal_learn_more_about_authentication_tokens": "Apprenez-en davantage sur les jetons d’authentification de l’intégration Git.", "git_bridge_modal_read_only": "Vous disposez d'un accès en lecture seule à ce projet. Cela signifie que vous pouvez extraire des données de __appName__, mais que vous ne pouvez pas transférer les modifications que vous apportez à ce projet.", "git_sync": "Synchronisation Git", - "git_sync_description": "Pousse de force les fichiers du projet vers un dépôt git externe. Incluez votre jeton d'authentification dans l'URL (ex. https://user:token@github.com/org/repo.git).", + "git_sync_description": "Synchronisez votre projet avec un dépôt git externe. Les fichiers binaires (images, etc.) sont exclus de la poussée — git n'est pas adapté aux ressources binaires. Incluez votre jeton d'authentification dans l'URL.", "git_sync_pull_now": "Tirer depuis git", "git_sync_pull_success": "Projet mis à jour depuis le dépôt git avec succès.", "git_sync_pulling": "Récupération…",