This repository has no description
0

Configure Feed

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

2configs.services.flix.ipfs: add hourly MFS/cid-map reconciliation

+59
+59
2configs/services/flix/ipfs.nix
··· 221 221 $IPFS routing provide "$root" >/dev/null 2>&1 || true 222 222 ${pkgs.coreutils}/bin/rm -f "$DIRTY_FLAG" 223 223 ''; 224 + 225 + # Periodic reconciliation: walks cid-map.txt and repairs stale state for 226 + # files that no longer exist on disk. Protects against inotify event 227 + # drops (e.g. queue overflow during bulk renames/deletes) and any other 228 + # path that leaves cid-map/MFS out of sync with the filesystem. 229 + reconcileScript = pkgs.writers.writeBash "flix-index-reconcile" '' 230 + set -efu 231 + 232 + IPFS="${pkgs.kubo}/bin/ipfs" 233 + CID_MAP="${cidMapFile}" 234 + DOWNLOAD_ROOT="${downloadRoot}" 235 + FLIX_INDEX="${flixIndexMfs}" 236 + DIRTY_FLAG="${dirtyFlag}" 237 + 238 + [ -f "$CID_MAP" ] || exit 0 239 + 240 + removed=0 241 + while IFS=' ' read -r cid path; do 242 + [ -n "$cid" ] || continue 243 + if [ ! -e "$path" ]; then 244 + rel="''${path#$DOWNLOAD_ROOT/}" 245 + $IPFS files rm "$FLIX_INDEX/$rel" >/dev/null 2>&1 || true 246 + $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 + removed=$((removed + 1)) 252 + fi 253 + done < "$CID_MAP" 254 + 255 + if [ "$removed" -gt 0 ]; then 256 + echo "reconciled: removed $removed stale entries" 257 + touch "$DIRTY_FLAG" 258 + fi 259 + ''; 224 260 in 225 261 { 226 262 # symlink /var/download into IPFS root so --nocopy works ··· 312 348 OnBootSec = "5min"; 313 349 OnUnitActiveSec = "2min"; 314 350 Unit = "flix-index-publish.service"; 351 + }; 352 + }; 353 + 354 + systemd.services.flix-index-reconcile = { 355 + description = "Reconcile flix MFS index / cid-map against filesystem"; 356 + after = [ "ipfs.service" ]; 357 + requires = [ "ipfs.service" ]; 358 + serviceConfig = { 359 + Type = "oneshot"; 360 + Environment = [ "IPFS_PATH=/var/lib/ipfs" ]; 361 + ExecStart = reconcileScript; 362 + User = config.services.kubo.user; 363 + Group = config.services.kubo.group; 364 + }; 365 + }; 366 + 367 + systemd.timers.flix-index-reconcile = { 368 + description = "Reconcile flix MFS index hourly"; 369 + wantedBy = [ "timers.target" ]; 370 + timerConfig = { 371 + OnBootSec = "15min"; 372 + OnUnitActiveSec = "1h"; 373 + Unit = "flix-index-reconcile.service"; 315 374 }; 316 375 }; 317 376