-
Notifications
You must be signed in to change notification settings - Fork 21
Make proxy media filenames content-adressable #76
base: master
Are you sure you want to change the base?
Conversation
I may need tips regards to how I would write a test for this, I was thinking literally making sure calling the function twice with the same name returns different SHAs? 😸 |
I ended up working it out, but I'm unsure if that single test is enough it just makes sure calling the function twice returns different SHAs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for the PR! Sorry, maybe I should have written a bit more clear description. Using the term "avoiding collisions" was a bit misleading.
We need the hashing to work the other way around, i.e. it should be deterministic with respect to the file contents. Two files with same contents (regardless of where they're stored on the file system and with what name) should always produce the exact same hash. So if you'd reimport a file, the proxy media would already be there and we could short-cirtcuit that conversion instead of doing it once again.
Ah ok so is it a case of just removing this randomising part of the function? |
Removing the randomness and using file contents, rather than file name, as the hash input. |
@owickstrom I've tried to research how to Hash a file content in Haskell, but I'm not aquatentced on the subject overall so not been able to work out what needs to be done. If you have any pointers that would be great 👍 |
@owickstrom totally forgot I was doing this!! is this still a valid PR and if so did you have any idea into hashing a file with Haskell? |
Hey @Cmdv! No worries, but feel free to pick this up again if you'd like. I don't have any pointers for you right now, but if I find some time I'll try to post some links. |
Description:
This pull requests fixes #24
Make sure to describe (where applicable):
createSHA1BaseName
could be tested to make sure given the same file name different SHA's are created, would that suffice?Checklist:
Please make sure to check the following items (that are applicable.)
How to test:
import new video file and look at the command line output to see the naming of files should be as follows:
TODO: Testing instructions for reviewer.
I split this functionality out into its own file as I was unsure where it could live. This is because the function could also be used with #72