# manually add a passed list of files to the local LFS store in a parallel manner bypassing filter-process | |
# original final revision of this script was lost. huggingface-cli also has functionality for bypassing git-lfs. | |
export GIT_DIR=$(git rev-parse --git-dir) | |
[ -d "$GIT_DIR" ] || exit -1 | |
parallel -i bash -vx -c '\ | |
sha=$(pv -c "{}" 2>/dev/tty | sha256sum | cut -d \ -f 1);\ | |
size=$(($(stat -c %s "{}")));\ | |
if (( size > 1024 )); then\ | |
dir="$GIT_DIR"/lfs/objects/${sha:0:2}/${sha:2:2}/;\ | |
mkdir -p "$dir";\ | |
mv "{}" "$dir"/${sha} && {\ | |
echo version https://git-lfs.github.com/spec/v1;\ | |
echo oid sha256:"$sha";\ | |
echo size "$size";\ | |
} > "{}" &&\ | |
git add "{}" || { mv "$dir"/${sha} "{}"; false; };\ | |
fi'\ | |
-- "$@" | |