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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bojanz’s picture

Status: Active » Needs review
FileSize
22.17 KB

This 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.

bojanz’s picture

Pushed the API refactoring:
http://drupalcode.org/project/commerce_file.git/commitdiff/4084598?hp=9e...

This patch is just the custom download logging.

bojanz’s picture

Status: Needs review » Fixed

Cleaned 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...

deggertsen’s picture

So with this, will it be necessary to have any other module to limit downloads?

bojanz’s picture

No, not anymore.

deggertsen’s picture

You're amazing @bojanz. Thank you.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.