Hi,
I have created a little patch that adds tokens for filehash so they may be used in other modules like file entity path (fe_paths) and possibly filefield_paths (fe_paths replaces this though).
This is useful to be able to change the way drupal stores files in paths according to the Content Addressable Storage (CAS http://en.wikipedia.org/wiki/Content-addressable_storage) pairtree spec by CDLib: http://www.slideshare.net/jakkbl/dcc-pair-posterppt
As well as the tokens for full md5, sha-1, sha-256, I have added two levels of pair tokens for each. So for example a md5 of 3998b02c5cd2723153c39701683a503b the file-md5-1 will be 39 and the file-md5-2 will be 98.
This means that in fe_paths you can set a token like:
/[file:file-md5-1]/[file:file-md5-2]/
And see storage paths like /files/39/98/
I have run this patch against Coder code review and it passed checks except for this existing one on filehash.install (I haven't touched this file, so it's unrelated):
filehash.install - severity: normalLine -1: @file block missing (Drupal Docs)
I also added a check on filehash_file_load to make sure the file variable was an object as sometimes a string is passed instead and it causes an error passing to filehash_save.
Please review and if you like it put it in -dev?
Thanks,
Christiaan Kortekaas
| Comment | File | Size | Author |
|---|---|---|---|
| filehash-cas_pairtree_tokens.patch | 2.52 KB | mrangryfish |
Comments
Comment #1
mfbSounds good. I would like to make a few changes. For example, the tokens should use the same translatable strings as the views handler.
Also, I am curious about hook_file_load() issue. Are you able to debug this and determine how a non-object is ending up in the $files array?
Comment #2
mfbI committed a revised version of this patch, with different tokens:
[file:filehash-sha1]
[file:filehash-sha1-pair-1]
[file:filehash-sha1-pair-2]
Please test and re-open if there are any issues.