From 1262d1d696045aa817a147631ecc38725a33c876 Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Thu, 15 Mar 2018 16:03:56 -0400 Subject: [PATCH] Shorten prefix to 2 characters Using 2 hex characters [0-9a-f] will give us 16 * 16 = 256 root folders which seems more manageable than 4096 (16^3). Assuming a user has 10,000 attachments, they should roughly distribute at ~40 per folder with prefix length 2 rather than ~2.5 per folder with a prefix of 3. --- app/types/attachment/write_attachment_data.js | 2 +- test/app/types/attachment/write_attachment_data_test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/types/attachment/write_attachment_data.js b/app/types/attachment/write_attachment_data.js index 947ea6785e..99a8cfb0cb 100644 --- a/app/types/attachment/write_attachment_data.js +++ b/app/types/attachment/write_attachment_data.js @@ -35,6 +35,6 @@ exports._getAttachmentName = () => { // _getAttachmentPath :: Unit -> IO Path exports._getAttachmentPath = () => { const name = exports._getAttachmentName(); - const prefix = name.slice(0, 3); + const prefix = name.slice(0, 2); return Path.join(prefix, name); }; diff --git a/test/app/types/attachment/write_attachment_data_test.js b/test/app/types/attachment/write_attachment_data_test.js index 61a992d883..ae7d768d52 100644 --- a/test/app/types/attachment/write_attachment_data_test.js +++ b/test/app/types/attachment/write_attachment_data_test.js @@ -12,7 +12,7 @@ const { } = require('../../../../app/types/attachment/write_attachment_data'); -const PREFIX_LENGTH = 3; +const PREFIX_LENGTH = 2; const NUM_SEPARATORS = 1; const NAME_LENGTH = 64; const PATH_LENGTH = PREFIX_LENGTH + NUM_SEPARATORS + NAME_LENGTH;