diff options
author | Marius Balteanu <marius.balteanu@zitec.com> | 2021-11-25 21:34:40 +0000 |
---|---|---|
committer | Marius Balteanu <marius.balteanu@zitec.com> | 2021-11-25 21:34:40 +0000 |
commit | 79e7cde849ffa6b4f7a6e37eb9b5893a05d481ca (patch) | |
tree | 1cf0d8cf90687ebcdaaa1cab65f804fc0547c4a8 /lib | |
parent | 5865edeba731bdb5a0e5bff17c6ec3ba08d941e7 (diff) | |
download | redmine-79e7cde849ffa6b4f7a6e37eb9b5893a05d481ca.tar.gz redmine-79e7cde849ffa6b4f7a6e37eb9b5893a05d481ca.zip |
Fix plugin assets are no longer copied under plugin name (#36218, #29914, #32938).
git-svn-id: http://svn.redmine.org/redmine/trunk@21295 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/plugin_loader.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/redmine/plugin_loader.rb b/lib/redmine/plugin_loader.rb index 43219a116..7b05a8a3d 100644 --- a/lib/redmine/plugin_loader.rb +++ b/lib/redmine/plugin_loader.rb @@ -38,21 +38,24 @@ module Redmine def mirror_assets return unless has_assets_dir? + destination = File.join(PluginLoader.public_directory, 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(destination, File.dirname(source_files.first).gsub(assets_dir, '')) begin FileUtils.mkdir_p(base_target_dir) rescue => e raise "Could not create directory #{base_target_dir}: " + e.message end end + 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(destination, dir.gsub(assets_dir, '')) begin FileUtils.mkdir_p(target_dir) rescue => e @@ -60,7 +63,7 @@ module Redmine end end source_files.each do |file| - target = File.join(PluginLoader.public_directory, file.gsub(assets_dir, '')) + target = File.join(destination, file.gsub(assets_dir, '')) unless File.exist?(target) && FileUtils.identical?(file, target) FileUtils.cp(file, target) end |