add preliminary check to avoid adding same barcode twice or to multible products

This commit is contained in:
Riley L. 2025-01-02 00:54:20 +01:00
parent e69972dc87
commit 49dbe1baa7

View file

@ -746,6 +746,17 @@ local function r_products_post()
if barcode == nil or barcode:match(matchers_global.barcode) == nil then
return error_box("{+error.invalid_barcode}")
end
local exists = false
for _, a_barcode in read_barcodes() do
if a_barcode == barcode then
exists = true
end
end
if exists then
return error_box("{+error.invalid_barcode}")
end
local barcodes = io.open("barcodes", "a+")
if barcodes == nil then
return error_box("{+error.open_barcodes}")