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
|
end
|
||||||
# add attachments
|
# add attachments
|
||||||
part["attachments"] = []
|
part["attachments"] = []
|
||||||
dir = PUBLIC + "/" + ATTACHMENTS + "/" + part["name"]
|
dir = PUBLIC + "/" + ATTACHMENTS + "/" + part["name"].gsub("/", "_")
|
||||||
if File.directory?(dir) then
|
if File.directory?(dir) then
|
||||||
Dir.entries(dir).each do |file|
|
Dir.entries(dir).each do |file|
|
||||||
path = dir + "/" + file
|
path = dir + "/" + file
|
||||||
next unless File.file? path
|
next unless File.file? path
|
||||||
part["attachments"] << ATTACHMENTS + "/" + part["name"] + "/" + file
|
part["attachments"] << ATTACHMENTS + "/" + part["name"].gsub("/", "_") + "/" + file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
part["attachments"].sort!
|
part["attachments"].sort!
|
||||||
|
@ -429,7 +429,7 @@ get '/import/lcsc/:lcsc' do
|
||||||
(part["attachments"] + [part["datasheet"]]).each do |attachment|
|
(part["attachments"] + [part["datasheet"]]).each do |attachment|
|
||||||
next unless attachment
|
next unless attachment
|
||||||
file = attachment.split("/")[-1]
|
file = attachment.split("/")[-1]
|
||||||
dir = PUBLIC + "/" + ATTACHMENTS + "/" + part["name"]
|
dir = PUBLIC + "/" + ATTACHMENTS + "/" + part["name"].gsub("/", "_")
|
||||||
path = "#{dir}/#{i}_#{file}"
|
path = "#{dir}/#{i}_#{file}"
|
||||||
i += 1
|
i += 1
|
||||||
unless File.file?(path) then
|
unless File.file?(path) then
|
||||||
|
|
Loading…
Reference in New Issue