Chunks: use a prefix of the chunk for a subdirectory.

Filesystems don't handle massive directories too well, so better to split.
Using the prefix of the chunk gives us a maximum of 64 * 64 = 4096 entries
in the main directory.
This commit is contained in:
Tom Hacohen 2020-08-04 15:37:07 +03:00
parent 393b85d3ca
commit e385aa8f20

View File

@ -87,7 +87,9 @@ def chunk_directory_path(instance, filename):
col = instance.collection
user_id = col.owner.id
return Path('user_{}'.format(user_id), col.uid, instance.uid)
uid_prefix = instance.uid[:2]
uid_rest = instance.uid[2:]
return Path('user_{}'.format(user_id), col.uid, uid_prefix, uid_rest)
class CollectionItemChunk(models.Model):