server: fix attachment folder name
This commit is contained in:
parent
b265820fc7
commit
af835ff358
|
@ -127,12 +127,12 @@ def get_part_by_id(id)
|
|||
end
|
||||
# add attachments
|
||||
part["attachments"] = []
|
||||
dir = PUBLIC + "/" + ATTACHMENTS + "/" + part["name"]
|
||||
dir = PUBLIC + "/" + ATTACHMENTS + "/" + part["name"].gsub("/", "_")
|
||||
if File.directory?(dir) then
|
||||
Dir.entries(dir).each do |file|
|
||||
path = dir + "/" + file
|
||||
next unless File.file? path
|
||||
part["attachments"] << ATTACHMENTS + "/" + part["name"] + "/" + file
|
||||
part["attachments"] << ATTACHMENTS + "/" + part["name"].gsub("/", "_") + "/" + file
|
||||
end
|
||||
end
|
||||
part["attachments"].sort!
|
||||
|
@ -429,7 +429,7 @@ get '/import/lcsc/:lcsc' do
|
|||
(part["attachments"] + [part["datasheet"]]).each do |attachment|
|
||||
next unless attachment
|
||||
file = attachment.split("/")[-1]
|
||||
dir = PUBLIC + "/" + ATTACHMENTS + "/" + part["name"]
|
||||
dir = PUBLIC + "/" + ATTACHMENTS + "/" + part["name"].gsub("/", "_")
|
||||
path = "#{dir}/#{i}_#{file}"
|
||||
i += 1
|
||||
unless File.file?(path) then
|
||||
|
|
Loading…
Reference in New Issue