Part-DB / Part-DB-server

Part-DB is an Open source inventory management system for your electronic components
https://docs.part-db.de/
GNU Affero General Public License v3.0
903 stars 100 forks source link

Most JPG image attachments are not found after PartKeepr import #291

Closed mindsolve closed 1 year ago

mindsolve commented 1 year ago

Describe the bug After importing the data from PartKeepr, following the instructions, some attachments are not available/marked as "not found" in the UI.

Based on my research, the file extension does not match for JPEG images, where the extension field in the PartKeepr DB is empty. PartDB assumes the extension to be .jpg, while PartKeepr used .jpeg (at least in my instances). In the PartDB database, the filepath is recorded as %SECURE%/PartAttachment/6f8b40d2-1976-11e8-928b-0242c84f1654.jpg, whereas the actual file lives at %SECURE%/PartAttachment/6f8b40d2-1976-11e8-928b-0242c84f1654.jpeg.

To Reproduce Steps to reproduce the behavior:

  1. Import PartKeepr database and attachments according to https://docs.part-db.de/partkeepr_migration.html
  2. Open a part with a JPEG attachment
  3. Observe the File not found marking on the attachment

Expected behavior I expected PartDB to be able to view all attachments that were visible in PartKeepr.

Screenshots

Server Side

Desktop (please complete the following information):

Smartphone (please complete the following information): n/a

Additional context

jbtronics commented 1 year ago

PartKeepr seems to use just the second part of the mimetype (e.g. "jpeg" of "image/jpeg"), when no explicit extension was set. That also meant that the file extension of the saved file were jpeg, even if the uploaded file had a jpg extension. I changed the import function to emulate the PartKeepr behavior and with the latest master commits it should work properly.

I also fixed some import bugs related to importing price information of Parts: Now currencies are correctly imported too. However in cases where there are the same price informations, but in different currencies, you will have to delete the prices in one of the currencies, when editing the part the next time. Part-DB automatically calculates prices in your favorite currency based on a defined exchange rate, and giving one price in multiple currencies could lead to conflicts.

mindsolve commented 1 year ago

Thanks a lot! Just to make sure I understand correctly: I have to re-import the PartKeepr Database for this fix to work?

jbtronics commented 1 year ago

Yes. The change was in the import routine, so you have to redo the import (which also means that your database will be purged again).