summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoofar <toofar@spalge.com>2023-01-03 17:19:55 +1300
committertoofar <toofar@spalge.com>2023-01-03 19:12:07 +1300
commit8e996f3d67a5e55a94f70b88d751f339b6c95a88 (patch)
tree733599561cbd646a96aeb29a291623b574f5f3b6
parent6576c03de08d7878f11d5869c119a1767bf3c897 (diff)
downloadqutebrowser-8e996f3d67a5e55a94f70b88d751f339b6c95a88.tar.gz
qutebrowser-8e996f3d67a5e55a94f70b88d751f339b6c95a88.zip
handle strangely empty cached files in caching filter
Weird, not sure where these empty files are coming from. Also tell pyupgrade to always return 0 where nothing odd happens.
-rwxr-xr-xscripts/check_mergability.sh22
1 files changed, 20 insertions, 2 deletions
diff --git a/scripts/check_mergability.sh b/scripts/check_mergability.sh
index 5bab9a98c..5120e8c01 100755
--- a/scripts/check_mergability.sh
+++ b/scripts/check_mergability.sh
@@ -297,7 +297,7 @@ cat > "\$inputf"
usort () { env usort format -; }
black () { env black -q -; }
isort () { env isort -q -; }
-pyupgrade () { env pyupgrade --py37-plus -; }
+pyupgrade () { env pyupgrade --exit-zero-even-if-changed --py37-plus -; }
run_with_cache () {
inputf="\$1"
@@ -307,7 +307,25 @@ run_with_cache () {
mkdir -p "/tmp/filter-caches/\$cmds/\$cmd" 2>/dev/null
outputf="/tmp/filter-caches/\$cmds/\$cmd/\$input_hash"
- [ -e "\$outputf" ] || \$cmd < "\$inputf" > "\$outputf"
+ if [ -e "\$outputf" ] ;then
+ lines="\$(wc -l "\$outputf" | cut -d' ' -f1)"
+ # where are these empty output files coming from???
+ # echo "removing bad cached file '\$outputf'" >&2
+ [ \$lines -eq 0 ] && rm "\$outputf"
+ fi
+
+ if ! [ -e "\$outputf" ] ;then
+ \$cmd < "\$inputf" > "\$outputf"
+ [ \$? -eq 0 ] || {
+ echo "\$cmd failed" >&2
+ cat "\$inputf"
+ return
+ }
+ lines="\$(wc -l "\$outputf" | cut -d' ' -f1)"
+ [ \$lines -eq 0 ] && {
+ echo "tool '\$cmd' produced 0 line output file from '\$inputf'" >&2
+ }
+ fi
cat "\$outputf"
}