# -*- mode:sh -*-

function purgeempty() {
    log "Purging empty directories"
    local archiveroot

    for archive in "${public_archives[@]}"; do
        log "... archive: ${archive}"
        archiveroot="$(get_archiveroot "${archive}")"

        # FIXME: double find
        if [ ! -z "$(find ${archiveroot}/pool/ -type d -empty)" ]; then
            find ${archiveroot}/pool/ -type d -empty | xargs rmdir;
        fi
    done
}

function gitcleanup() {
    log "Doing git stuff"
    cd ${public}/git/dak.git
    git gc --prune
    git update-server-info
    # now workaround a git bug not honoring the setup in logs/*
    # (fix in development, but until it reached backports.org.......)
    chmod -R g+w logs/
}

function fixsymlinks() {
    log "Fixing symlinks"
    local archiveroot

    for archive in "${public_archives[@]}"; do
        log "... archive: ${archive}"
        archiveroot="$(get_archiveroot "${archive}")"
        symlinks -d -r ${archiveroot}
    done
}
