Skip to content

Commit

Permalink
Merge pull request #588 from ivan-hc/dev
Browse files Browse the repository at this point in the history
Improve speed of -a / about, -l / list and -f / files
  • Loading branch information
ivan-hc authored May 22, 2024
2 parents 40f58bd + 7f96b4a commit 46d74b6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 35 deletions.
2 changes: 1 addition & 1 deletion APP-MANAGER
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

AMVERSION="6.8.1"
AMVERSION="6.8.2"

# Determine main repository and branch
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
Expand Down
13 changes: 9 additions & 4 deletions modules/database.am
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ function _list() {
ITEMSNUMBER=$(("$ITEMSNUMBER"-1))
fi
APPSNUMBER=$(echo "$(("$ITEMSNUMBER" - "$LIBNUMBER"))")
_check_version
if test -f $AMPATH/.cache/version-args; then
INSTALLED=$(cat $AMPATH/.cache/version-args | sort | sed 's/ | / /g' | grep -v "◆ am ")
if test -f "$AMPATH"/.cache/version-args; then
INSTALLED=$(cat "$AMPATH"/.cache/version-args | sort | sed 's/ | / /g' | grep -v "◆ am ")
MESSAGE2="\n$INSTALLED\n"
else
_check_version
INSTALLED=$(cat "$AMPATH"/.cache/version-args | sort | sed 's/ | / /g' | grep -v "◆ am ")
MESSAGE2="\n$INSTALLED\n"
fi

Expand Down Expand Up @@ -116,7 +119,9 @@ case "$1" in
exit
;;
esac
_check_version
if ! test -f "$AMPATH"/.cache/version-args; then
_check_version
fi

# Main logic
if [ ! -f "$AMPATH/libs-list" ]; then
Expand Down
74 changes: 44 additions & 30 deletions modules/files.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ function _files_header() {
}
function _files() {
rm -f $AMPATH/.cache/files-args*
rm -f "$AMPATH"/.cache/files-args*
cd $APPSPATH &&
INSTALLED_APPS=$(find -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2> /dev/null | sort -rh | sed 's@.* @@')
_check_version
if ! test -f "$AMPATH"/.cache/version-args; then
_check_version
fi
for arg in $INSTALLED_APPS; do
if test -f ./$arg/remove 2>/dev/null; then
if grep -q "usr/local/lib" ./$arg/remove; then
Expand All @@ -26,80 +28,92 @@ function _files() {
else
SIZE=$(du -sh -- $arg | cut -f1 -d" ")
fi
APPVERSION=$(cat $AMPATH/.cache/version-args | grep -w "$arg |" | sed 's:.*| ::')
APPVERSION=$(cat "$AMPATH"/.cache/version-args | grep -w "$arg |" | sed 's:.*| ::')
if [ -z "$(strings -d "./$arg/$arg" 2>/dev/null | grep -F 'if you run it with the --appimage-extract option')" ] 2>/dev/null; then
string=$(strings -d "./$arg/$arg" 2>/dev/null | head -1 )
if grep -q "usr/local/lib" ./$arg/remove; then
echo "$arg | $APPVERSION | library | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | library | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
elif echo "$string" | grep -q "ld-linux"; then
echo "$arg | $APPVERSION | binary/executable | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | binary/executable | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
elif echo "$string" | grep -q "#!"; then
echo "$arg | $APPVERSION | script | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | script | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
elif ! test -f "./$arg/$arg"; then
link_in_path=$(cat "./$arg/remove" | tr " " "\n" | grep 'local/bin' | tail -1)
realpath=$(realpath "$link_in_path")
realstring=$(strings -d "$realpath" 2>/dev/null | head -1 )
if [[ -L "$link_in_path" ]]; then
if echo "$realstring" | grep -q "ld-linux"; then
echo "$arg | $APPVERSION | binary/executable | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | binary/executable | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
elif echo "$realstring" | grep -q "#!"; then
echo "$arg | $APPVERSION | script | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | script | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
else
echo "$arg | $APPVERSION | unknown | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | unknown | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
fi
elif cat "./$arg/remove" | tail -1 | grep -q 'xtype l -exec rm'; then
echo "$arg | $APPVERSION | set/tools | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | set/tools | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
elif echo "$realstring" | grep -q "#!"; then
script2path=$(cat "$link_in_path" | tail -1 | sed 's#$APP#'$arg'#g' | sed 's#exec ##g')
realrealstring=$(strings -d "$script2path" 2>/dev/null | head -1 )
if echo "$realrealstring" | grep -q "ld-linux"; then
echo "$arg | $APPVERSION | binary/executable | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | binary/executable | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
elif echo "$realrealstring" | grep -q "#!"; then
echo "$arg | $APPVERSION | script | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | script | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
elif [[ $(test -f "$link_in_path") != 0 ]]; then
echo "$arg | $APPVERSION | launcher | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | launcher | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
else
echo "$arg | $APPVERSION | unknown | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | unknown | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
fi
else
echo "$arg | $APPVERSION | other | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | other | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
fi
else
echo "$arg | $APPVERSION | other | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | other | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
fi
else
if [ -z "$(strings -d "./$arg/$arg" 2>/dev/null | grep -F 'AppImages require FUSE to run')" ] 2>/dev/null; then
echo "$arg | $APPVERSION | appimage-type3 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | appimage-type3 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
else
echo "$arg | $APPVERSION | appimage-type2 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> $AMPATH/.cache/files-args
echo "$arg | $APPVERSION | appimage-type2 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args
fi
fi
fi
done
}
if test -f "$AMPATH"/.cache/remove-args; then
rm -f "$AMPATH"/.cache/files-args*
rm -f "$AMPATH"/.cache/remove-args
fi
if [ "$2" = "--less" ]; then
cd "$APPSPATH" &&
find . -type f -name 'remove' 2>/dev/null | sed -r 's|/[^/]+$||' | sort | uniq | wc -l
exit 0
elif [ "$2" = "--byname" ]; then
_files_header
_files
echo "- APPNAME | VERSION | TYPE | SIZE " >> $AMPATH/.cache/files-args-byname
echo "- ------- | ------- | ---- | ----" >> $AMPATH/.cache/files-args-byname
if test -f $AMPATH/.cache/files-args; then
cat $AMPATH/.cache/files-args | sort >> $AMPATH/.cache/files-args-byname
echo "- APPNAME | VERSION | TYPE | SIZE " >> "$AMPATH"/.cache/files-args-byname
echo "- ------- | ------- | ---- | ----" >> "$AMPATH"/.cache/files-args-byname
if test -f "$AMPATH"/.cache/files-args; then
rm -f "$AMPATH"/.cache/files-args-byname
cat "$AMPATH"/.cache/files-args | sort >> "$AMPATH"/.cache/files-args-byname
else
_files
rm -f "$AMPATH"/.cache/files-args-byname
cat "$AMPATH"/.cache/files-args | sort >> "$AMPATH"/.cache/files-args-byname
fi
cat $AMPATH/.cache/files-args-byname | column -t
cat "$AMPATH"/.cache/files-args-byname | column -t
echo ""
else
_files_header
_files
echo "- APPNAME | VERSION | TYPE | SIZE " >> $AMPATH/.cache/files-args-bysize
echo "- ------- | ------- | ---- | ----" >> $AMPATH/.cache/files-args-bysize
if test -f $AMPATH/.cache/files-args; then
cat $AMPATH/.cache/files-args >> $AMPATH/.cache/files-args-bysize
echo "- APPNAME | VERSION | TYPE | SIZE " >> "$AMPATH"/.cache/files-args-bysize
echo "- ------- | ------- | ---- | ----" >> "$AMPATH"/.cache/files-args-bysize
if test -f "$AMPATH"/.cache/files-args; then
rm -f "$AMPATH"/.cache/files-args-bysize
cat "$AMPATH"/.cache/files-args >> "$AMPATH"/.cache/files-args-bysize
else
_files
rm -f "$AMPATH"/.cache/files-args-bysize
cat "$AMPATH"/.cache/files-args >> "$AMPATH"/.cache/files-args-bysize
fi
cat $AMPATH/.cache/files-args-bysize | column -t
cat "$AMPATH"/.cache/files-args-bysize | column -t
echo ""
fi

0 comments on commit 46d74b6

Please sign in to comment.