Commit 90b4b3ea authored by Antoine Le Gonidec's avatar Antoine Le Gonidec

2.8 - meta-script - Add script identification by file name

parent 717a55ad
......@@ -23,7 +23,6 @@ if [ -z "$PLAYIT_LIB2" ]; then
fi
. "$PLAYIT_LIB2"
check_deps 'md5sum'
if [ ! -f "$INPUT_FILE" ]; then
print_error
......@@ -39,20 +38,47 @@ if [ ! -f "$INPUT_FILE" ]; then
return 1
fi
FILE_MD5="$(md5sum $INPUT_FILE | cut --delimiter=' ' --fields=1)"
SCRIPT="$(grep --dereference-recursive --files-with-matches "$FILE_MD5" ~/.local/share/play.it/play.it-* | sort --reverse | head --lines=1)"
# Locate script by file name
FILE_NAME="${INPUT_FILE##*/}"
case "${LANG%_*}" in
('fr')
string='Recherche d’un script par nom de fichier pour le fichier %s\n'
;;
('en'|*)
string='Looking for a script by file name for file %s\n'
;;
esac
printf "$string" "$FILE_NAME"
SCRIPT="$(grep --dereference-recursive --files-with-matches "ARCHIVE_.\\+='$FILE_NAME'" ~/.local/share/play.it/play.it-* | sort --reverse | head --lines=1)"
# Locate script by file MD5 checksum
if [ -z "$SCRIPT" ]; then
case "${LANG%_*}" in
('fr')
string='Recherche d’un script par somme de contrôle MD5 pour le fichier %s\n'
;;
('en'|*)
string='Looking for a script by MD5 hash sum for file %s\n'
;;
esac
printf "$string" "$FILE_NAME"
check_deps 'md5sum'
FILE_MD5="$(md5sum $INPUT_FILE | cut --delimiter=' ' --fields=1)"
SCRIPT="$(grep --dereference-recursive --files-with-matches "$FILE_MD5" ~/.local/share/play.it/play.it-* | sort --reverse | head --lines=1)"
SCRIPT_OPTIONS='--checksum=none'
fi
if [ -z "$SCRIPT" ]; then
print_error
case "${LANG%_*}" in
('fr')
string='Impossible de trouver un script pour la somme MD5 %s\n'
string='Impossible de trouver un script pour le fichier %s\n'
;;
('en'|*)
string='Could not find script for hash %s\n'
string='Could not find script for file %s\n'
;;
esac
printf "$string" "$FILE_MD5"
printf "$string" "$FILE_NAME"
return 1
fi
......@@ -60,6 +86,6 @@ PLAYIT_LIB="$HOME/.local/share/play.it/play.it-1/play-anything.sh"
export PLAYIT_LIB
export PLAYIT_LIB2
"$SCRIPT" "$INPUT_FILE" --checksum=none "$@"
"$SCRIPT" "$INPUT_FILE" $SCRIPT_OPTIONS "$@"
exit 0
2.8.0
* Greatly reduce time taken by play.it meta-script to identify the correct
script for an archive, by using file name before falling back on MD5 hash
sum
2.7.5
* Fix sort_icons behaviour when icon extraction produced a single file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment