Defect #36218
Plugin assets are not copied correctly in trunk r21289
Status: | Closed | Start date: | ||
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | % 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/
- public/plugin_assets/view_customize/
- public/plugin_assets/
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
Associated revisions
History
#1
Updated by Marius BALTEANU 6 months ago
- Status changed from New to Confirmed
- Assignee set to Marius BALTEANU
- Target version set to 5.0.0
#2
Updated by Marius BALTEANU 6 months ago
- Related to Feature #32938: Rails 6: Zeitwerk support added
#3
Updated by Marius BALTEANU 6 months ago
- Related to Feature #29914: Migrate to Rails 6.1 with Zeitwerk autoloading added
#4
Updated by Marius BALTEANU 6 months 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 6 months ago
I have confirmed that this has been fixed.
Thank you very much.