fix bugs i introduced in refactoring
authorIan Kelling <ian@iankelling.org>
Thu, 3 Oct 2024 04:03:37 +0000 (00:03 -0400)
committerIan Kelling <ian@iankelling.org>
Thu, 3 Oct 2024 04:03:37 +0000 (00:03 -0400)
filesystem/usr/local/bin/mount-latest-subvol

index 201d4dc3e648159f0df393cb0deeb0b296c924df..019d16a251a231788f1638d6b350abdbed8988cf 100755 (executable)
@@ -151,10 +151,10 @@ get-btrfs-root-mountpoint() {
   fi
 }
 
-# Input vars: $vol $root_dir (from get-btrfs-root-mountpoint)
+# Input vars: $vol, PWD=$root_dir (from get-btrfs-root-mountpoint)
 expire-leaf-vols() {
   local leaf_vols count leaf_limit_time  leaf_new_limit_time leaf
-  leaf_vols=($root_dir/$vol.leaf.*)
+  leaf_vols=($vol.leaf.*)
   count=${#leaf_vols[@]}
   leaf_limit_time=$(( EPOCHSECONDS - 60*60*24*60 )) # 60 days
   leaf_new_limit_time=$(( EPOCHSECONDS - 60*60*24 * 5 )) # 5 days
@@ -162,7 +162,7 @@ expire-leaf-vols() {
   # This goes backwards from oldest. leaf_new_limit_time is to avoid
   # deleting very recent leafs.
   for leaf in ${leaf_vols[@]}; do
-    leaf_time=$(date -d ${leaf##"$vol".leaf.} +%s)
+    leaf_time=$(date -d ${leaf#$vol.leaf.} +%s)
     if (( leaf_limit_time > leaf_time || ( leaf_new_limit_time > leaf_time && count > 30 ) )); then
       b btrfs sub del $leaf
     fi
@@ -455,7 +455,6 @@ plan-umounts() {
           to_umount=($dir)
         fi
       done
-      umount-dirs-add ${binds[@]} $d
     else
       mnt $d ${binds[@]}
     fi