pR0Ps / PhotoFloat

See https://git.zx2c4.com/PhotoFloat/ (this is a personal fork)
GNU General Public License v2.0
24 stars 2 forks source link

Rework thumbnail cache directory structure #4

Closed pR0Ps closed 7 years ago

pR0Ps commented 7 years ago

Use the SHA1 hash of the original file to create a path like so: cache/thumbs/[1st 2 chars of hash]/[rest of hash]_[size].jpg

This allows for using symlinks in the album folder to put a picture in multiple folders without creating duplicate cache entries. A use case of this would be using a symlink farm as a tagging system or alternate layout in the album directory.

It will also scale better with extreme amounts of pictures since it won't just drop thousands of files in the same directory.

Even though the thumbnails themselves will have hashes as filenames, optimally, the URLs used to access them should still be readable filenames. It follows then that the javascript will have to translate the URL into the correct file hash before displaying it.

Mockup

cache/
├── thumbs/
│   ├── 00
│   │   ├── hashhashhashhashhashhashhashhashhashha_75s.jpg
│   │   ├── hashhashhashhashhashhashhashhashhashha_1600.jpg
│   │   └── ...
│   ├── ...
│   └── ff
│       └── ...
└─ [json data]