This repository has no description
0

Configure Feed

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

services/flix/ipfs: watch new subdirectories for files

+32
+32
2configs/services/flix/ipfs.nix
··· 79 79 done < "$CID_MAP" 80 80 log "Cleanup complete" 81 81 82 + # watch a new subdirectory for files 83 + watch_new_dir() { 84 + local dir="$1" 85 + log "Watching new directory: $dir" 86 + # first add any files already in it 87 + ${pkgs.findutils}/bin/find "$dir" -type f | while read -r f; do 88 + add_file "$f" 89 + done 90 + # then watch for new files 91 + $INOTIFYWAIT -m -r \ 92 + -e close_write \ 93 + -e moved_to \ 94 + -e moved_from \ 95 + -e delete \ 96 + "$dir" | 97 + while read -r d event f; do 98 + path="''${d}''${f}" 99 + case "$event" in 100 + CLOSE_WRITE*|MOVED_TO*) 101 + add_file "$path" 102 + ;; 103 + DELETE*|MOVED_FROM*) 104 + remove_file "$path" 105 + ;; 106 + esac 107 + done 108 + } 109 + 82 110 # watch for changes 83 111 log "Watching directories: ${lib.concatStringsSep ", " watchDirs}" 84 112 $INOTIFYWAIT -m -r \ ··· 86 114 -e moved_to \ 87 115 -e moved_from \ 88 116 -e delete \ 117 + -e create \ 89 118 ${lib.escapeShellArgs watchDirs} | 90 119 while read -r dir event file; do 91 120 path="''${dir}''${file}" 92 121 case "$event" in 122 + CREATE,ISDIR*|MOVED_TO,ISDIR*) 123 + watch_new_dir "$path" & 124 + ;; 93 125 CLOSE_WRITE*|MOVED_TO*) 94 126 add_file "$path" 95 127 ;;