From e385aa8f20ef6f160e43a5461b9603c870b5716e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 4 Aug 2020 15:37:07 +0300 Subject: [PATCH] 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. --- django_etebase/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/django_etebase/models.py b/django_etebase/models.py index 403d2b7..7570bae 100644 --- a/django_etebase/models.py +++ b/django_etebase/models.py @@ -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):