Hi All,

Have a bit of an issue where no downloads are showing up in the download counter. I installed the module as per usual and have verified that the file_downloads table is created, however no data is being inserted into the table. At first I thought this may have been due to the fact I only had pre-existing file attachments (nothing new since installing download_count) so I created a new node and attached a small file. However the same happens and no download data is recorded in the DB or displayed in the download_center page. Has anyone got any ideas why this might be as I feel like I am missing something really obvious in my setup?

Comments

Chill35’s picture

At first I thought this may have been due to the fact I only had pre-existing file attachments (nothing new since installing download_count) so I created a new node and attached a small file.

The download counter should work with previously attached files. It starts to count downloads on whatever file is attached after the module is installed, whether the file is attached before the module is installed or after.

One way to debug the problem is to look at your logs. When you (or anyone else) downloads a file attached to a node, is there a logging message that says that this file has been downloaded ?

Is the file attached to a CCK or Flexinode node ?

Thanks for trying out the module by the way, it's brand-spanking new.

Chill35’s picture

My wording was confusing. Let me rephrase it :

The module starts to count downloads as soon as the module is installed on whatever file is attached, whether the file is attached before the module is installed or afterwards.

Chill35’s picture

Just a sanity check here : the module counts downloads, not uploads. After uploading a file to a node, you have to download it once to test if the module works. Just in case there was a misunderstanding here about what the module does.

brashquido’s picture

Yep, definitely checking downloads :). I just had a look at my logs and there is no download entries there. In fact there is no download message type which as I read the module description should be there. I'm using Drupal 4.7.6 on a Windows 2003 Server with IIS6 and PHP 4.4.1 if it makes any difference?

Chill35’s picture

LOL Ok ;)

Is the node a special kind of node ? (CCK, Flexinode)

Chill35’s picture

FYI, the module will work with files that have been uploaded using the (core) upload module. In other words, files that are e-commerce products or 'quickfiles'... I don't know if the module will work for these.

Here's something to check : the file that you downloaded, is it in the {files} table in your database ? That's the table used by the core upload module.

Chill35’s picture

If you know php, you can debug the module this way.

Here's how the module works : it uses a module hook function : whenever a file that was uploaded /w upload.module is downloaded, the hook function download_count gets called in all modules if it ever is defined in them. So you can add this line at the beggining of the function download_count_file_download in download_count.module :


function download_count_file_download($filename) {

drupal_set_message('The download_count module has been called.');

Then download a file and see if there's a box that shows up when you refresh the page that says : "The download_count module has been called."

Chill35’s picture

Oupsy, it ain't the hook function download_count that gets called in all modules, it's {module_name}_file_download() that gets called. Sorry for that typo.

Chill35’s picture

Component: User interface » Code
Assigned: Unassigned » Chill35
Category: support » bug
Priority: Normal » Critical

There is something wrong with how the database is created. I will fix that for tomorrow. Thanks for reporting your failure to use the module :)

brashquido’s picture

Wow, you have been busy in the last half hour :). Glad I was able to help in someway, and I look forward to the fix :)

Chill35’s picture

As it turns out, brashquido, it looks like the hook function is called only when files have been downloaded using 'private download'. There's nothing wrong with the created database.

Are you using public download ? (i.e. Public - files are available using http directly.)
Please look in your admin/settings in section File system settings.

Let me know. If that really is the problem, I will make it clear on the project page that the module only works for private downloads.

Thanks for checking this out for me.

Chill35’s picture

Just to clarify, when downloading a file that was "publically" uploaded, the file is available for download using HTTP. The file is downloaded without going through Drupal AT ALL. Because Drupal is totally unaware that the file is being downloaded, then nothing can be recorded about the said download.

Our posts crossed. Please confirm if you're using 'public upload' by checking in your admin/settings in section File system settings. Thanks in advance ;)

Chill35’s picture

Scrap that : Just to clarify, when downloading a file that was "publically" uploaded with download method set to public, the file is available for download using HTTP.

brashquido’s picture

Spot on, that was it! Can't remember why I had files set to public, I vaguely remember there being some issue. Not to worry though, switching from public to private and now the downloads are being tracked in the download center. Thanks for your help, that would never have occurred to me :) .

Chill35’s picture

Component: Code » User interface
Category: bug » support
Priority: Critical » Normal
Status: Active » Closed (fixed)

No need to thank me : I have to thank you. I was always using private and did not even consider the public vs private issue.

I added an admin setting page to troubleshoot the possible overlook. The admin page checks whether the download method is set to private or public and says so.

I also updated the project page with this information. :)

brashquido’s picture

Excellent! Just figured out why I had the download method set to public. Until now I was tracking downloads using AWStats via my server log files, and with the download method set to private it doesn't seem to pick it up. The URI Stem changes from;

/files/filename.yar.gz

with public, to;

/index.php q=system/files/filename.tar.gz

with private. Doesn't matter now though with this module :)

alex288288’s picture

Title: Nothing showing in download center? » Nothing showing in download center? -quick question
Status: Closed (fixed) » Active

sooo...where is this download center everyone is talking about..i have looked around..if you could send me in the right area that would great

Chill35’s picture

It's in the Navigation menu. You can also type in http://myWebSite.com/download_counter to access the page.

You have admin settings for that module.

Chill35’s picture

Status: Active » Closed (fixed)
Tedhere’s picture

Version: 4.7.x-1.x-dev » 6.x-1.3

Help, If I have the download method set to Private then it will count the downloads BUT anonymous users get a "access denied" page when they try to download it.

Please show me what I'm overlooking. Thanks

Chill35’s picture

You need to grant to the role 'anonymous user' the permission to 'view uploaded files' on your admin/user/permissions page.