server: also update attachment path

This commit is contained in:
King Kévin 2023-01-31 00:06:09 +01:00
parent f8af750f02
commit eb66f0c81a
1 changed files with 7 additions and 0 deletions

View File

@ -264,6 +264,7 @@ def add_part(part)
insert.execute(part["name"])
part["id"] = statement.execute(part["name"]).to_a[0]["id"]
end
old_part = get_part_by_id(part["id"])
# update family
family = nil
field = "family"
@ -392,6 +393,12 @@ def add_part(part)
insert.execute(part["id"], ref["id"], row["quantity"])
end
end
# update attachments
dir_old = PUBLIC + "/" + ATTACHMENTS + "/" + old_part["name"].gsub("/", "_")
dir_new = PUBLIC + "/" + ATTACHMENTS + "/" + part["name"].gsub("/", "_")
unless dir_old == dir_new then
File.rename(dir_old, dir_new)
end
end
post '/part' do