Skip to content

Downloads counter not reliable - #278

Merged
luke- merged 3 commits into
masterfrom
enh/improve-download-counter
Mar 5, 2026
Merged

Downloads counter not reliable#278
luke- merged 3 commits into
masterfrom
enh/improve-download-counter

Conversation

@gevorgmansuryan

Copy link
Copy Markdown
Contributor

@gevorgmansuryan
gevorgmansuryan requested a review from luke- March 4, 2026 00:11
Comment thread widgets/views/fileSystemItem.php Outdated
<div class="title">
<i class="fa <?= $row->getIconClass(); ?>"></i>&nbsp;
<?php if ($row->getType() === "image") : ?>
<?php $galleryOptions = Yii::$app->getModule('cfiles')->settings->get('displayDownloadCount', false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain this? Why do we have different galleryOptions when the download counter is activated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luke- used to disable image cache by gallery plugin

Comment thread Events.php Outdated
return;
}

$event->action->enableHttpCache = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually prefer not to disable caching when the download counter is enabled.

In my opinion, it is not a problem if the download counter does not increase when the user already has the file in their cache.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luke- got it

Comment thread Events.php Outdated
return;
}

$deduplicationKey = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, to use the cache, to avoid tracking multiple times.

Basically, I don't think it's a bad idea if a user who has already downloaded the file is not counted again.

So what do you think about simply saving “trackedDownloads = [ids]” in the current user session?

That would be very lightweight.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luke- will be done in that way

@gevorgmansuryan
gevorgmansuryan requested a review from luke- March 4, 2026 19:46
@gevorgmansuryan

Copy link
Copy Markdown
Contributor Author

@luke- fixed

@luke-
luke- merged commit 605cc7d into master Mar 5, 2026
13 checks passed
@luke-
luke- deleted the enh/improve-download-counter branch March 5, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants