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
933 stars 108 forks source link

Help with Partkeepr attachment location in PartDB #712

Open GH15ADF opened 1 month ago

GH15ADF commented 1 month ago

This is a question, not really a bug per se.

I just migrated my database from Partkeepr to PartDB without any problems and now I am trying to put the attachment files in the proper directory. However, I am seeing the "file not found" icon in the UI. I attempted to follow the direction in the Migrate from PartKeepr to Part-DB page. The following is the directory structure in the original Partkeepr docker container:

root@9c045c08cb12:/var/www/html# tree -d data
data
|-- files
|   |-- FootprintAttachment
|   |-- PartAttachment
|   |-- ProjectAttachment
|   `-- Temporary
|-- iclogo
|-- images
|   |-- cache
|   |-- footprint
|   |-- iclogo
|   |-- part
|   `-- temp
`-- temp

This is the directory structure in the PartDB docker container: In PartDB docker container:

root@b89d0034f15c:/var/www/html/uploads# tree -d
.
`-- files
    |-- FootprintAttachment
    |-- PartAttachment
    |-- ProjectAttachment
    `-- Temporary

The other piece of information I will add is that inspecting the Sqlite DB directly, I see %SECURE%/PartAttachment/4dd95690-6a3b-11eb-869a-1fccd4923431.pdf in the path field of one of my imported parts.

I would have attempted to move the files to the corresponding location, but I cannot figure out how to determine what %SECURE% translates into as far as the file system in the docker container .

To Reproduce Steps to reproduce the behavior:

  1. Follow steps in PartkeepR Migration instructions
  2. Copy files into directory as specified in Step 4
  3. Restart docker container
  4. Login and search for known part (e.g., NE555)
  5. Observe "file not found" icon in the left column of the results on the attachments tab

Expected behavior See an icon related to the attachment (e.g., PDF) and be able to select the icon to see the attachment.

Screenshots 2024-09-16 12_17_21-PartDB_file_not_found

Server Side

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

jbtronics commented 1 month ago

The "%SECURE%" placeholder should map to the uploads/ folder in the Part-DB root (as long as you have not changed it).

So the placement of the files should be correct. Do the files have the correct permissions, so that the webserver can access (read and write) them? I would assume that especially with docker, it could be easy to get the permissions wrong.

GH15ADF commented 1 month ago

Thanks for the info and I confirm that I am running in Docker. After making the permission changes you suggested, I am still seeing "file not found". I did not knowingly change anything including %SECURE%. I'm not even sure I understand how that parameter is set.

As you mentioned, I did not have the correct owner:group on the uploads/ folders and children, so set them to www-data:www-data

root@b89d0034f15c:/var/www/html# ls -la uploads/
total 7927
drwxr-xr-x 3 www-data www-data         4 Sep 13 00:15 .
drwxr-xr-x 1 www-data www-data      4096 Sep  9 19:57 ..
drwxr-xr-x 6 www-data www-data         6 Feb  8  2021 files

I also modified all my directory permissions to 755 which matches the permissions in the public/media folders

root@b89d0034f15c:/var/www/html# tree -dp /var/www/html/uploads/files
[drwxr-xr-x]  /var/www/html/uploads/files
|-- [drwxr-xr-x]  FootprintAttachment
|-- [drwxr-xr-x]  PartAttachment
|-- [drwxr-xr-x]  ProjectAttachment
`-- [drwxr-xr-x]  Temporary

My attachment files permissions are now set to 644 because that is what I see when I inspect my one test attachment to a test part.

############# My test attachment ##################
root@b89d0034f15c:/var/www/html# ls -la /var/www/html/public/media/part/310/testattachment-66e5799bea4fb.pdf
-rw-r--r-- 1 www-data www-data 37832 Sep 14 11:55 /var/www/html/public/media/part/310/testattachment-66e5799bea4fb.pdf
############# attachment file not found part ##################
root@b89d0034f15c:/var/www/html# ls -la /var/www/html/uploads/files/PartAttachment/4dd95690-6a3b-11eb-869a-1fccd4923431.pdf
-rw-r--r-- 1 www-data www-data 1731903 Feb  8  2021 /var/www/html/uploads/files/PartAttachment/4dd95690-6a3b-11eb-869a-1fccd4923431.pdf

Can I look at log entries or turn on logging to troubleshoot? I looked around in /var/log in the Docker container but there is not much there.

jbtronics commented 1 month ago

In docker container the logs are available via dockers log mechanism. (So you can view them for example with docker logs)