I2P Address: [http://git.idk.i2p]

Skip to content

Introduce persister that uses a directory structure

Zlatin Balevsky requested to merge github/fork/LoveIsGrief/change-persister into master

Created by: LoveIsGrief

Related to #36 (closed)

Using the base64 SHA-256 of the shared file's absolute path, a folder structure of <muwireHome>/files/<hash[:6]>/<hash[6:>.json. The cut length of the hash was chosen pretty randomly, I admit, but the goal is reduce the number of json files in one folder and reduce the number of possible folders.

A migration from the files.json is also in this PR.

Advantages:

  • json files are updated individually when a file has been hashed
  • reduced write speed
  • basically a hashmap so access is O(1)
  • no extra library needed

Disadvantages:

  • One JSON per file --> increased inode count
  • No hash collision check
  • unwieldy pathnames

Possible improvements:

  • the pathnames are quite long so maybe a different hash algorithm can be chosen
  • cut length was chosen randomly so maybe a clever calculation calculate the optimal length for a good balance between directory count and file count per directory
  • another subdirectory level for less files per directory

Merge request reports

Loading