Project

General

Profile

Actions

Defect #36218

closed

Plugin assets are not copied correctly in trunk r21289

Added by Hirokazu Onozato over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Category:
Code cleanup/refactoring
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
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 supportClosedMarius BĂLTEANU

Actions
Related to Redmine - Feature #29914: Migrate to Rails 6.1 with Zeitwerk autoloadingClosedGo MAEDA

Actions
Related to Redmine - Defect #36273: Modifying the source code of a plugin does not reload it after r21295ClosedGo MAEDA

Actions
Actions #1

Updated by Marius BĂLTEANU over 2 years ago

  • Status changed from New to Confirmed
  • Assignee set to Marius BĂLTEANU
  • Target version set to 5.0.0
Actions #2

Updated by Marius BĂLTEANU over 2 years ago

Actions #3

Updated by Marius BĂLTEANU over 2 years ago

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

Updated by Marius BĂLTEANU over 2 years 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.

Actions #5

Updated by Hirokazu Onozato over 2 years ago

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

Actions #6

Updated by Go MAEDA over 1 year ago

  • Related to Defect #36273: Modifying the source code of a plugin does not reload it after r21295 added
Actions

Also available in: Atom PDF