fix: extract brand assets - handle subfolders in zip file (#83)
* fix: handle subfolders in zip file * fix: simplify move operation * chore: rubocop
This commit is contained in:
parent
8e76517e2f
commit
138e4d3c01
@ -35,7 +35,7 @@ module Whatsapp::BaileysHandlers::Helpers # rubocop:disable Metrics/ModuleLength
|
||||
end
|
||||
end
|
||||
|
||||
def message_type # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
||||
def message_type # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength,Metrics/AbcSize
|
||||
msg = @raw_message[:message]
|
||||
if msg.key?(:conversation) || msg.dig(:extendedTextMessage, :text).present?
|
||||
'text'
|
||||
|
||||
@ -13,39 +13,6 @@ ZIP_FILE="$TEMP_DIR/downloaded_favicons.zip"
|
||||
EXTRACT_DIR="$TEMP_DIR/extracted_favicons"
|
||||
TARGET_DIR="public"
|
||||
|
||||
EXPECTED_FILES="
|
||||
android-icon-36x36.png
|
||||
android-icon-48x48.png
|
||||
android-icon-72x72.png
|
||||
android-icon-96x96.png
|
||||
android-icon-144x144.png
|
||||
android-icon-192x192.png
|
||||
apple-icon-57x57.png
|
||||
apple-icon-60x60.png
|
||||
apple-icon-72x72.png
|
||||
apple-icon-76x76.png
|
||||
apple-icon-114x114.png
|
||||
apple-icon-120x120.png
|
||||
apple-icon-144x144.png
|
||||
apple-icon-152x152.png
|
||||
apple-icon-180x180.png
|
||||
apple-icon.png
|
||||
apple-icon-precomposed.png
|
||||
apple-touch-icon.png
|
||||
apple-touch-icon-precomposed.png
|
||||
favicon-16x16.png
|
||||
favicon-32x32.png
|
||||
favicon-96x96.png
|
||||
favicon-512x512.png
|
||||
favicon-badge-16x16.png
|
||||
favicon-badge-32x32.png
|
||||
favicon-badge-96x96.png
|
||||
ms-icon-70x70.png
|
||||
ms-icon-144x144.png
|
||||
ms-icon-150x150.png
|
||||
ms-icon-310x310.png
|
||||
"
|
||||
|
||||
cleanup() {
|
||||
echo "Cleaning up temporary files..."
|
||||
rm -rf "$TEMP_DIR"
|
||||
@ -71,20 +38,7 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Checking for expected files..."
|
||||
MISSING_FILES=0
|
||||
for filename in $EXPECTED_FILES; do
|
||||
if ! find "$EXTRACT_DIR" -name "$filename" -print | grep -q .; then
|
||||
echo "Warning: Expected file '$filename' not found in the zip archive."
|
||||
MISSING_FILES=$((MISSING_FILES + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$MISSING_FILES" -gt 0 ]; then
|
||||
echo "$MISSING_FILES expected file(s) were not found in the zip archive."
|
||||
fi
|
||||
|
||||
echo "Moving extracted files to $TARGET_DIR/..."
|
||||
mv "$EXTRACT_DIR"/* "$TARGET_DIR/" 2>/dev/null || true
|
||||
echo "Flattening all files from extracted archive…"
|
||||
find "$EXTRACT_DIR" -type f -exec mv -f {} "$TARGET_DIR/" \;
|
||||
|
||||
echo "Process completed."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user