Product images disappearing

I imported a ton of product images by downloading them to the respective /var/lib/dolibarr/documents/produit/REF folders and they are all owned by root so they cannot be changed/deleted by dolibarr and they are fine.
But when I upload a picture to a product via the web interface it deletes it after an unknown amount of time.
The reference still exists in the llx_ecm_files table but the file AND FOLDER for the product are gone!
Am I doing something wrong?