From ff26a71bd96e29b8ef7a70a649760a3562913d45 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sat, 15 Aug 2020 22:23:49 -0700 Subject: [PATCH] taskd/clone.sh: add another check for exceeding size limit On some systems, the file size limit may not stick or may not be fully implemented. Go ahead and check for a file that's too big after a successful clone just in case we're running on such a system. While it's too late to prevent use of the extra space at this point, at least it will be quickly freed up once detected which is better than nothing. Signed-off-by: Kyle J. McKay --- taskd/clone.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/taskd/clone.sh b/taskd/clone.sh index 1e1aaa6..a9aad6b 100755 --- a/taskd/clone.sh +++ b/taskd/clone.sh @@ -655,6 +655,18 @@ case "$url" in ;; esac +# For systems that do not properly implement the file size limit, +# perform a check here just in case. Unfortunately by this time +# the excess space has already been used, but at least it will +# be reclaimed almost immediately if we detect an overage here. +if [ "${cfg_max_file_size512:-0}" != "0" ]; then + toobig="$(find -H objects -type f -size +$(( $cfg_max_file_size512 - 1 )) -print 2>/dev/null | + head -n 1)" || : + if [ -n "$toobig" ]; then + exit 1 # fail the clone + fi +fi + # Check the max_clone_objects setting now (if set) if [ "${cfg_max_clone_objects:-0}" != "0" ]; then objcount="$(git count-objects -v | LC_ALL=C awk 'BEGIN{v=0}/^count:/||/^in-pack:/{v+=$2}END{print v}')" || : -- 2.11.4.GIT