This repository has no description
0

Configure Feed

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

mailserver: fix notmuch-flag-sync Seen flag detection

The grep patterns (',.*S' and '-v ,.*S') matched Dovecot's size
metadata (,S=7520) instead of the actual Maildir Seen flag after :2,.
This prevented read status from propagating from notmuch to IMAP.

Replace grep-based filtering with case statements that check the
flags field after :2, correctly.

+7 -5
+7 -5
2configs/mailserver.nix
··· 308 308 export NOTMUCH_CONFIG="${ 309 309 self.packages.${pkgs.system}.notmuch.passthru.configuration.configFile.path 310 310 }" 311 + # First, pick up any IMAP flag changes into notmuch 312 + ${pkgs.notmuch}/bin/notmuch new --quiet 2>/dev/null || true 311 313 # Add S flag to files notmuch considers read but that lack it 312 314 ${pkgs.notmuch}/bin/notmuch search --output=files 'NOT tag:unread' \ 313 - | ${pkgs.gnugrep}/bin/grep -v ',.*S' \ 314 315 | ${pkgs.gnugrep}/bin/grep '/cur/' \ 315 316 | while IFS= read -r f; do 316 317 [ -f "$f" ] || continue 317 - base="''${f%:2,*}" 318 318 flags="''${f##*:2,}" 319 + case "$flags" in *S*) continue ;; esac 320 + base="''${f%:2,*}" 319 321 mv "$f" "''${base}:2,''${flags}S" 320 322 done 321 323 # Remove S flag from files notmuch considers unread but that have it 322 324 ${pkgs.notmuch}/bin/notmuch search --output=files 'tag:unread' \ 323 - | ${pkgs.gnugrep}/bin/grep ',.*S' \ 324 325 | ${pkgs.gnugrep}/bin/grep '/cur/' \ 325 326 | while IFS= read -r f; do 326 327 [ -f "$f" ] || continue 327 - base="''${f%:2,*}" 328 328 flags="''${f##*:2,}" 329 - newflags="$(echo "$flags" | ${pkgs.gnused}/bin/sed 's/S//g')" 329 + case "$flags" in *S*) ;; *) continue ;; esac 330 + base="''${f%:2,*}" 331 + newflags="''${flags//S/}" 330 332 mv "$f" "''${base}:2,''${newflags}" 331 333 done 332 334 # Update notmuch DB with the renames