Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: MasseR/shellscripts
base: 53bc6fc739
...
head fork: MasseR/shellscripts
compare: f7a4dd53ee
  • 4 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 79 additions and 0 deletions.
  1. +79 −0 bin/mailindex
View
79 bin/mailindex
@@ -0,0 +1,79 @@
+#!/bin/bash
+# This is UNUSABLE as is. The indexing is too slow without the -newer flag, but
+# with it, it skips new files. The thing is that mutt preservers the mtime when
+# it moves the mails from new to cur, which leads us to two possibilities. If
+# we scan the new directory, we get the files, but as mutt moves them from new
+# to cur, they are not rescanned, and the next purge removes them entirely. If
+# we don't scan the new directory, we still update the mtime of the index,
+# which we use for checking new files. This results to a situation where the
+# index file is newer than those files in the cur directories.
+
+MAILDIR=$HOME/Mail
+SEARCHDIR=$MAILDIR/Search
+CASKET=$HOME/Mail/casket
+
+search="no"
+mutt="no"
+
+while getopts "iacpeos:mh" flags
+do
+ case $flags in
+ "i") # Index
+ # For initial indexing, remove the -mtime part
+ find_new=""
+ if [ -d $CASKET ]; then
+ find_new="-newer $CASKET/_fwm"
+ fi
+ find $MAILDIR -type f -path '*/cur/*' $find_new | grep -v "Search" | egrep 'cur' | estcmd gather -bc -cl -fm -cm $CASKET -
+ ;;
+ "a") # Index all
+ find $MAILDIR -type f -path '*/cur/*' | grep -v "Search" | egrep 'cur' | estcmd gather -bc -cl -fm -cm $CASKET -
+ ;;
+ "c") # Create new
+ find $MAILDIR -type f -path '*/cur/*' | egrep 'cur' | estcmd gather -bc -tr -fm $CASKET -
+ ;;
+ "p") # Purge
+ estcmd purge $CASKET
+ ;;
+ "e") # Extract keys
+ estcmd extkeys $CASKET
+ ;;
+ "o") # Optimize
+ estcmd optimize $CASKET
+ ;;
+ "s") # Search
+ search=$OPTARG
+ ;;
+ "m") # Mutt mode
+ mutt="yes"
+ ;;
+ "h")
+ echo "mailindex [options]"
+ echo -e "\t-h\t\tThis help text"
+ echo -e "\t-c\t\tCreate a new index"
+ echo -e "\t-i\t\tIndex mail"
+ echo -e "\t-p\t\tPurge index"
+ echo -e "\t-o\t\tOptimize index"
+ echo -e "\t-e\t\tExtract keys"
+ echo -e "\t-s [arg]\tSearch"
+ echo -e "\t-m\t\tMutt mode"
+ esac
+
+done
+
+if [ "$search" != "no" ]
+then
+ if [ $mutt == "yes" ]
+ then
+ rm $SEARCHDIR/cur/*
+ for file in $(estcmd search -max 1000 -vu $CASKET "$search" | gawk '/file:/ {print gensub("file://", "", "", $2)}' | perl -pe 's/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg')
+ do
+ if [ -e $file ]; then
+ ln $file $SEARCHDIR/cur/
+ fi
+ done
+ echo "$(ls $SEARCHDIR/cur | wc -l) results"
+ else
+ estcmd search -vh $CASKET "$search"
+ fi
+fi

No commit comments for this range

Something went wrong with that request. Please try again.