# Submitted by: Adrian Bunk  (2006-02-07 17:41)
# 
# It was a bit annoying that mutt was no longer able to figure out
# which folders contained new emails after a backup run. This patch 
# fixes this by adding --atime-preserve to invocations of tar.

# default tar driver, but with --atime-preserve
DRIVER_ATIME_TAR ()
{
    case $1 in
        -test)
            require_tools tar
            echo "ok"
            ;;
        -suffix)
            echo "tar"
            ;;
        -create)        # Arguments: $2 = BID, $3 = archive file name, $4 = file list file
            tar cf $3 --numeric-owner --no-recursion --atime-preserve -T $4 2>&1 \
                | grep -v 'tar: Removing leading .* from .* names'
            ;;
        -toc)           # Arguments: $2 = BID, $3 = archive file name
            tar tf $3 | sed 's#^#/#'
            ;;
        -extract)       # Arguments: $2 = BID, $3 = archive file name, $4 = file list file
            tar xf $3  --same-permission --same-owner --numeric-owner -T $4 2>&1
            ;;
    esac
}

# default tar.gz driver, but with --atime-preserve
DRIVER_ATIME_TAR_GZ ()
{
    case $1 in
        -test)
            require_tools tar
            echo "ok"
            ;;
        -suffix)
            echo "tar.gz"
            ;;
        -create)        # Arguments: $2 = BID, $3 = archive file name, $4 = file list file
            tar czf $3 -T $4 --no-recursion --atime-preserve 2>&1 \
                | grep -v 'tar: Removing leading .* from .* names'
            ;;
        -toc)           # Arguments: $2 = BID, $3 = archive file name
            tar tzf $3 | sed 's#^#/#'
            ;;
        -extract)       # Arguments: $2 = BID, $3 = archive file name, $4 = file list file
            tar zx --same-permission --same-owner -f $3 -T $4 2>&1
            ;;
    esac
}

# default tar.bz2 driver, but with --atime-preserve
DRIVER_ATIME_TAR_BZ2 ()
{
    case $1 in
        -test)
            require_tools tar bzip2
            echo "ok"
            ;;
        -suffix)
            echo "tar.bz2"
            ;;
        -create)        # Arguments: $2 = BID, $3 = archive file name, $4 = file list file
            tar cjf $3 -T $4 --no-recursion --atime-preserve 2>&1 \
                | grep -v 'tar: Removing leading .* from .* names'
            ;;
        -toc)           # Arguments: $2 = BID, $3 = archive file name
            tar tjf $3 | sed 's#^#/#'
            ;;
        -extract)       # Arguments: $2 = BID, $3 = archive file name, $4 = file list file
            tar jx --same-permission --same-owner -f $3 -T $4 2>&1
            ;;
    esac
}

