Open Pdzly opened 1 month ago
I don't have any issues uploading files with the same name. Have you noticed this issue somehow?
@jgrim its rather not good to have the images named like they do originally.
Best it should be directly identifiable e.g. {uploader.id}-{random-hash}.png/jpg/webm
Edit: If lemmy has something different, pictrs just ignores the names and deduplicates it with image file hashes
We dont know if they have it in any meta data but idk
Pictrs doesn't store the actual image file itself, and nowhere on the filesystem or sled repo, is the uploaded file name. The identifier EG: e47-35c3e-95038ded-7a46-4d1a is in the pictrs Database to the filename/path in the Lemmy Database. pictrs uses sled for it's database. Lemmy code connects with it and translates as LEMMY needs, with it's requests/Database.
In pictrs there is no such thing as a 'duplicate filename'. There is a concept of 'duplicate file or file pieces'.
Sled uses modern b-tree techniques such as prefix encoding and suffix truncation for reducing the storage costs of long keys with shared prefixes. If keys are the same length and sequential then the system can avoid storing 99%+ of the key data in most cases, essentially acting like a learned index
ls
equiv on the object storage for filenames:
73689 Images/002/449/684/2bd0ad8e-5c54-4447-891b-e9eaf35c721b
2348777 Images/002/449/684/6a5955c1-0171-4b43-b6fb-b3b0d0e6673b
15996 Images/002/449/685/cd0e98a5-892a-41ac-a271-f038c7fcb2bf
2922 Images/002/449/686/2cc9a21f-e982-4aed-bf4e-6a3963048564
Currently if a user uploads "A cute teddybear.jpg" it stays "A cute teddybear..." on the server this could lead to duplicates / errors if another "A cute teddybear" gets uploaded.
I would recommend to name them "{person.id}-{file.name}-{date}" So it could be identified just by looking into the file name who uploaded it and when.