Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions git-reader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,11 @@ For example, every 5 minutes in a cronjob:
```bash
*/5 * * * * docker run ...
```

## 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.
25 changes: 23 additions & 2 deletions git-reader/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ 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.
# 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}"
fi
if [ -n "${LFS_FETCH_EXCLUDE:-}" ]; then

@alexcottner alexcottner Jul 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much work would it be to abstract this a little bit more so the param could be just a list of buckets/collections?

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
LOG_PREFIX="init"
Expand Down Expand Up @@ -125,7 +147,6 @@ cmd_gitupdate() {
log "Fetch completed in $(fmt_duration $(($(date +%s) - start_total)))."
}


git_fetch_lfs() {
local repo_path="$1"

Expand All @@ -149,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

Expand Down
Loading