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:
Gabriel Jablonski 2025-07-16 18:05:42 -03:00 committed by GitHub
parent 8e76517e2f
commit 138e4d3c01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 49 deletions

View File

@ -35,7 +35,7 @@ module Whatsapp::BaileysHandlers::Helpers # rubocop:disable Metrics/ModuleLength
end end
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] msg = @raw_message[:message]
if msg.key?(:conversation) || msg.dig(:extendedTextMessage, :text).present? if msg.key?(:conversation) || msg.dig(:extendedTextMessage, :text).present?
'text' 'text'

View File

@ -13,39 +13,6 @@ ZIP_FILE="$TEMP_DIR/downloaded_favicons.zip"
EXTRACT_DIR="$TEMP_DIR/extracted_favicons" EXTRACT_DIR="$TEMP_DIR/extracted_favicons"
TARGET_DIR="public" 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() { cleanup() {
echo "Cleaning up temporary files..." echo "Cleaning up temporary files..."
rm -rf "$TEMP_DIR" rm -rf "$TEMP_DIR"
@ -71,20 +38,7 @@ else
exit 1 exit 1
fi fi
echo "Checking for expected files..." echo "Flattening all files from extracted archive…"
MISSING_FILES=0 find "$EXTRACT_DIR" -type f -exec mv -f {} "$TARGET_DIR/" \;
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 "Process completed." echo "Process completed."