FIX: Do not error when importing a theme with empty files

FIX: Do not error when importing a theme with empty files

diff --git a/app/models/remote_theme.rb b/app/models/remote_theme.rb
index 895cc17..8bda923 100644
--- a/app/models/remote_theme.rb
+++ b/app/models/remote_theme.rb
@@ -149,7 +149,7 @@ class RemoteTheme < ActiveRecord::Base
     end
 
     # Destroy fields that no longer exist in the remote theme
-    field_ids_to_destroy = theme.theme_fields.pluck(:id) - updated_fields.map(&:id)
+    field_ids_to_destroy = theme.theme_fields.pluck(:id) - updated_fields.map { |tf| tf&.id }
     ThemeField.where(id: field_ids_to_destroy).destroy_all
 
     if !skip_update
diff --git a/spec/models/remote_theme_spec.rb b/spec/models/remote_theme_spec.rb
index eca5828..2a9ae32 100644
--- a/spec/models/remote_theme_spec.rb
+++ b/spec/models/remote_theme_spec.rb
@@ -47,6 +47,7 @@ describe RemoteTheme do
         "about.json" => about_json,
         "desktop/desktop.scss" => scss_data,
         "scss/file.scss" => ".class1{color:red}",
+        "scss/empty.scss" => "",
         "common/header.html" => "I AM HEADER",
         "common/random.html" => "I AM SILLY",
         "common/embedded.scss" => "EMBED",

GitHub sha: 42853678

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there: