server: fix attachment folder name

This commit is contained in:
King Kévin 2023-01-30 04:37:35 +01:00
parent b265820fc7
commit af835ff358
1 changed files with 3 additions and 3 deletions

View File

@ -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