From 274d4c76c9b769f5055e87ab1c9079638e1a1927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Gon=C3=A7alves?= Date: Sat, 23 Nov 2024 17:20:52 -0300 Subject: [PATCH] Update snap package list after 24h without update this --- usr/share/biglinux/bigstore-cli/snap_cache.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usr/share/biglinux/bigstore-cli/snap_cache.sh b/usr/share/biglinux/bigstore-cli/snap_cache.sh index b5ac431..1149cac 100755 --- a/usr/share/biglinux/bigstore-cli/snap_cache.sh +++ b/usr/share/biglinux/bigstore-cli/snap_cache.sh @@ -33,6 +33,11 @@ FileToSaveCacheFiltered="$cacheFolderHome/snap_filtered.json" AllSnapCache="$cacheFolderHome/snap_all_pkgs.cache" InstalledSnap="$cacheFolderHome/snap_Installed_pkgs.cache" +# If user not root, cache doesn't exist or is older than 24 hours, generate it +if [ "$UID" -ne 0 ] && { [[ ! -e $AllSnapCache ]] || [[ $(find "$AllSnapCache" -mmin +1440 -print) ]]; }; then + snap_download.sh +fi + # # Installed packages LANG=C snap list | awk 'NR>1 { print $1 "\t" $2}' | sort -u >$InstalledSnap & @@ -94,4 +99,4 @@ else awk_file="$awk_folder/snap_cache_without_translate.awk" fi -awk -v installedPackages="$InstalledSnap" $awk_translate -f $awk_file "$AllSnapCache" | sort -u >$FileToSaveCacheFiltered \ No newline at end of file +awk -v installedPackages="$InstalledSnap" $awk_translate -f $awk_file "$AllSnapCache" | sort -u >$FileToSaveCacheFiltered