The file_download_count and download_count modules are great for tracking who and when has downloaded each file.
We already integrate with file_download_count and there's no reason why we can't integrate with download_count as well.
At this moment, we are also using the file_download_count integration to log downloads in order to do download limiting, but that is the wrong approach to take. The reason is simple, limitations need to be resettable, for instance when a license is renewed, so at that point the log needs to be flushed.
Flushing general stats in order to accomplish this is obviously wrong, so it makes more sense to reintroduce a small log entity and use that for download limits.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2047035-2-file-download-logging.patch | 13.39 KB | bojanz |
#1 | 2047035-file-download-logging.patch | 22.17 KB | bojanz |
Comments
Comment #1
bojanz CreditAttribution: bojanz commentedThis works, I will give it another pass and commit tonight.
It intentionally doesn't make the log an entity, it is not meant to be user viewable and can be reset at any time.
file_download_count should still be used for actual stats.
Changes in this patch:
1) A file can be licensed from multiple products. The first found license (age wise) is used.
2) Downloads can now be limited without file_download_count.
The logs take the license_id into account, increasing the counts of the correct license.
This also allows the counts for a specific license to be reset, when a license is renewed, for instance.
Comment #2
bojanz CreditAttribution: bojanz commentedPushed the API refactoring:
http://drupalcode.org/project/commerce_file.git/commitdiff/4084598?hp=9e...
This patch is just the custom download logging.
Comment #3
bojanz CreditAttribution: bojanz commentedCleaned up the code comments, moved the file download logging to hook_exit() so that it doesn't happen for incomplete downloads.
Committed.
http://drupalcode.org/project/commerce_file.git/commitdiff/239509d?hp=40...
Comment #4
deggertsen CreditAttribution: deggertsen commentedSo with this, will it be necessary to have any other module to limit downloads?
Comment #5
bojanz CreditAttribution: bojanz commentedNo, not anymore.
Comment #6
deggertsen CreditAttribution: deggertsen commentedYou're amazing @bojanz. Thank you.