Defect #36218

Plugin assets are not copied correctly in trunk r21289

Added by Hirokazu Onozato 17 days ago. Updated 11 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Marius BALTEANU% Done:

0%

Category:Code cleanup/refactoring
Target version:-
Resolution:Fixed Affected version:

Description

Plugin assets were not copied correctly.

If the plugin assets are placed as shown below
  • plugins/view_customize/assets/
Previously, it has been copied to the public directory as follows.
  • public/plugin_assets/view_customize/
In r21289 of trunk, it is copied as follows.
  • public/plugin_assets/
It seems that the plugin name is missing.
There seems to be a problem with the processing of plugin_loader.rb.

I fixed the following as a test, and it was copied as before.

Index: plugin_loader.rb
===================================================================
--- plugin_loader.rb    (revision 21289)
+++ plugin_loader.rb    (working copy)
@@ -38,11 +38,12 @@
     def mirror_assets
       return unless has_assets_dir?

+      plugin_name = File.basename(@dir)
       source_files = Dir["#{assets_dir}/**/*"]
       source_dirs = source_files.select { |d| File.directory?(d)}
       source_files -= source_dirs
       unless source_files.empty?
-        base_target_dir = File.join(PluginLoader.public_directory, File.dirname(source_files.first).gsub(assets_dir, ''))
+        base_target_dir = File.join(PluginLoader.public_directory, plugin_name, File.dirname(source_files.first).gsub(assets_dir, ''))
         begin
           FileUtils.mkdir_p(base_target_dir)
         rescue => e
@@ -52,7 +53,7 @@
       source_dirs.each do |dir|
         # strip down these paths so we have simple, relative paths we can
         # add to the destination
-        target_dir = File.join(PluginLoader.public_directory, dir.gsub(assets_dir, ''))
+        target_dir = File.join(PluginLoader.public_directory, plugin_name, dir.gsub(assets_dir, ''))
         begin
           FileUtils.mkdir_p(target_dir)
         rescue => e
@@ -60,7 +61,7 @@
         end
       end
       source_files.each do |file|
-        target = File.join(PluginLoader.public_directory, file.gsub(assets_dir, ''))
+        target = File.join(PluginLoader.public_directory, plugin_name, file.gsub(assets_dir, ''))
         unless File.exist?(target) && FileUtils.identical?(file, target)
           FileUtils.cp(file, target)
         end

Related issues

Related to Redmine - Feature #32938: Rails 6: Zeitwerk support Closed
Related to Redmine - Feature #29914: Migrate to Rails 6.1 with Zeitwerk autoloading Closed

Associated revisions

Revision 21295
Added by Marius BALTEANU 11 days ago

Fix plugin assets are no longer copied under plugin name (#36218, #29914, #32938).

History

#1 Updated by Marius BALTEANU 16 days ago

  • Status changed from New to Confirmed
  • Assignee set to Marius BALTEANU
  • Target version set to 5.0.0

#2 Updated by Marius BALTEANU 11 days ago

#3 Updated by Marius BALTEANU 11 days ago

  • Related to Feature #29914: Migrate to Rails 6.1 with Zeitwerk autoloading added

#4 Updated by Marius BALTEANU 11 days ago

  • Category set to Code cleanup/refactoring
  • Status changed from Confirmed to Closed
  • Target version deleted (5.0.0)
  • Resolution set to Fixed

Patch committed with a test, thanks for pointing this out.

#5 Updated by Hirokazu Onozato 11 days ago

I have confirmed that this has been fixed.
Thank you very much.

Also available in: Atom PDF