#!/bin/bash

set -e


case "$1" in
    configure|upgrade|update|reconfigure)
        # Check if icon cache is downloaded
        if [ ! -d "/var/lib/swcatalog/icons" ] || [ -z "$(ls -A /var/lib/swcatalog/icons)" ]; then
            echo "Updating AppStream cache for application icons..."
            apt-get update -qq
            appstreamcli refresh-cache --force >/dev/null 2>&1
        fi
        
        ;;
        
    abort-upgrade|abort-remove|abort-deconfigure)
        ;;
        
    triggered)
        ;;
        
    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
