This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

2configs.services.flix.ipfs: fix reconcile for paths with special chars ([] etc)

+12 -5
+12 -5
2configs/services/flix/ipfs.nix
··· 237 237 238 238 [ -f "$CID_MAP" ] || exit 0 239 239 240 + # Rebuild cid-map in one pass, collecting stale entries to clean up. 241 + # Avoids sed regex issues with special chars like [ ] in paths. 242 + # Small race with pin-watcher's concurrent appends — any line the 243 + # watcher writes during this loop may be lost, but will be re-added 244 + # on the next inotify event or watcher restart. 245 + tmp=$(${pkgs.coreutils}/bin/mktemp) 240 246 removed=0 241 247 while IFS=' ' read -r cid path; do 242 248 [ -n "$cid" ] || continue 243 - if [ ! -e "$path" ]; then 249 + if [ -e "$path" ]; then 250 + echo "$cid $path" >> "$tmp" 251 + else 244 252 rel="''${path#$DOWNLOAD_ROOT/}" 245 253 $IPFS files rm "$FLIX_INDEX/$rel" >/dev/null 2>&1 || true 246 254 $IPFS pin rm "$cid" >/dev/null 2>&1 || true 247 - # drop this exact line from cid-map. small race with the watcher 248 - # (same tool it uses in remove_file), acceptable since reconcile 249 - # is idempotent across runs. 250 - ${pkgs.gnused}/bin/sed -i "\|^$cid $path$|d" "$CID_MAP" 251 255 removed=$((removed + 1)) 252 256 fi 253 257 done < "$CID_MAP" 254 258 255 259 if [ "$removed" -gt 0 ]; then 260 + ${pkgs.coreutils}/bin/mv "$tmp" "$CID_MAP" 256 261 echo "reconciled: removed $removed stale entries" 257 262 touch "$DIRTY_FLAG" 263 + else 264 + ${pkgs.coreutils}/bin/rm -f "$tmp" 258 265 fi 259 266 ''; 260 267 in