From 537d83643f3eb6b8419c52ec178d12f8f483a972 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Thu, 23 Jul 2026 14:22:54 +0200 Subject: [PATCH 1/3] git-reader: gitupdate: pass LFS config via env vars --- git-reader/README.md | 5 +++++ git-reader/run.sh | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/git-reader/README.md b/git-reader/README.md index ac8184bff..5c14d9d6a 100644 --- a/git-reader/README.md +++ b/git-reader/README.md @@ -129,3 +129,8 @@ For example, every 5 minutes in a cronjob: ```bash */5 * * * * docker run ... ``` + +## Git Source Settings + +- ``LFS_CONCURRENT_TRANSFERS`` (default: 8): increase number of parallel requests for LFS downloads. +- ``LFS_FETCH_EXCLUDE`` (default: none): exclude certains collections from LFS (eg. `"attachments/main-workspace/translation-dictionaries/*,attachments/main-workspace/quicksuggest-amp/*"`) diff --git a/git-reader/run.sh b/git-reader/run.sh index c7fb9f222..09d40f742 100644 --- a/git-reader/run.sh +++ b/git-reader/run.sh @@ -30,6 +30,17 @@ cmd_gitupdate() { start_total=$(date +%s) log "Repository path is $repo_path" + # Apply LFS tuning from environment variables. If a variable is not set, + # leave the corresponding Git config untouched. + if [ -n "${LFS_CONCURRENT_TRANSFERS:-}" ]; then + log "Setting lfs.concurrenttransfers to ${LFS_CONCURRENT_TRANSFERS}." + git config --global lfs.concurrenttransfers "${LFS_CONCURRENT_TRANSFERS}" + fi + if [ -n "${LFS_FETCH_EXCLUDE:-}" ]; then + log "Setting lfs.fetchexclude to ${LFS_FETCH_EXCLUDE}." + git config --global lfs.fetchexclude "${LFS_FETCH_EXCLUDE}" + fi + # Check if latest symlink exists. if [ ! -L "$repo_path/latest" ]; then LOG_PREFIX="init" From 06d967d1518f905e5120c26b7d1a6674c461a3dc Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Thu, 23 Jul 2026 17:15:00 +0200 Subject: [PATCH 2/3] type typo --- git-reader/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-reader/README.md b/git-reader/README.md index 5c14d9d6a..4a6cb032a 100644 --- a/git-reader/README.md +++ b/git-reader/README.md @@ -133,4 +133,4 @@ For example, every 5 minutes in a cronjob: ## Git Source Settings - ``LFS_CONCURRENT_TRANSFERS`` (default: 8): increase number of parallel requests for LFS downloads. -- ``LFS_FETCH_EXCLUDE`` (default: none): exclude certains collections from LFS (eg. `"attachments/main-workspace/translation-dictionaries/*,attachments/main-workspace/quicksuggest-amp/*"`) +- ``LFS_FETCH_EXCLUDE`` (default: none): exclude certain collections from LFS (eg. `"attachments/main-workspace/translation-dictionaries/*,attachments/main-workspace/quicksuggest-amp/*"`) From bc91abbb2504ef6fad7c6063cb84476d39021a14 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Fri, 24 Jul 2026 12:28:53 +0200 Subject: [PATCH 3/3] Control LFS history --- git-reader/README.md | 3 +++ git-reader/run.sh | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/git-reader/README.md b/git-reader/README.md index 4a6cb032a..6935de829 100644 --- a/git-reader/README.md +++ b/git-reader/README.md @@ -132,5 +132,8 @@ For example, every 5 minutes in a cronjob: ## Git Source Settings +With ``SELF_CONTAINED=true``, the attachments files are served by the application, and must be fetched using LFS. The following settings control disk usage and transfer speed. + - ``LFS_CONCURRENT_TRANSFERS`` (default: 8): increase number of parallel requests for LFS downloads. - ``LFS_FETCH_EXCLUDE`` (default: none): exclude certain collections from LFS (eg. `"attachments/main-workspace/translation-dictionaries/*,attachments/main-workspace/quicksuggest-amp/*"`) +- ``LFS_KEEP_DAYS`` (default: unset, see [LFS defaults](https://github.com/git-lfs/git-lfs/blob/main/docs/man/git-lfs-config.adoc)): a disk-space knob for the LFS cache that controls how many days of LFS history is retained beyond the current checkout. Objects referenced by ``HEAD`` are always kept. In Remote Settings terms, this means that clients trying to pull attachments of records that have been obsolete for more than `LFS_KEEP_DAYS` days will be served an error response. This can be mitigated using a caching layer on the reverse proxy, which would continue to serve obsolete attachments as long as they remained cached. diff --git a/git-reader/run.sh b/git-reader/run.sh index 09d40f742..d612784ca 100644 --- a/git-reader/run.sh +++ b/git-reader/run.sh @@ -32,6 +32,7 @@ cmd_gitupdate() { # Apply LFS tuning from environment variables. If a variable is not set, # leave the corresponding Git config untouched. + # We set them globally because they affect cloning. if [ -n "${LFS_CONCURRENT_TRANSFERS:-}" ]; then log "Setting lfs.concurrenttransfers to ${LFS_CONCURRENT_TRANSFERS}." git config --global lfs.concurrenttransfers "${LFS_CONCURRENT_TRANSFERS}" @@ -40,6 +41,16 @@ cmd_gitupdate() { log "Setting lfs.fetchexclude to ${LFS_FETCH_EXCLUDE}." git config --global lfs.fetchexclude "${LFS_FETCH_EXCLUDE}" fi + if [ -n "${LFS_KEEP_DAYS:-}" ]; then + # Control how much LFS history `git lfs prune` keeps on disk. Set to `0` for HEAD only. + log "Keeping ${LFS_KEEP_DAYS} extra day(s) of LFS history (HEAD is always kept)." + # recent refs: any branch/tags whose last commit is within these days. + git config --global lfs.fetchrecentrefsdays "${LFS_KEEP_DAYS}" + # recent commits: walks these ref tips to look for commits within these days. + git config --global lfs.fetchrecentcommitsdays "${LFS_KEEP_DAYS}" + # Extra safety margin added on top of above two. Set to 0 for above settings to be exact. + git config --global lfs.pruneoffsetdays 0 + fi # Check if latest symlink exists. if [ ! -L "$repo_path/latest" ]; then @@ -136,7 +147,6 @@ cmd_gitupdate() { log "Fetch completed in $(fmt_duration $(($(date +%s) - start_total)))." } - git_fetch_lfs() { local repo_path="$1" @@ -160,7 +170,7 @@ git_fetch_lfs() { log "Local HEAD: $local_head" log "Remote HEAD: $origin_head" if [ "$local_head" = "$origin_head" ]; then - log "No LFS updates..." + log "No update found." return 0 fi