Change the Marketpress temp location from var/tmp to something else

Hi there, I commented on an old thread here (https://premium.wpmudev.org/forums/topic/marketpress-writing-temp-files-to-vartmp) but I shouldn't have posted on the other one (sorry).

So, I have in this case a 22MB file I am selling via Marketpress. (I'm actually giving it away free at $0 if that makes a difference.) The problem is that with the demand I'm seeing, my var/tmp directory is filling up almost instantly, which is I understand where the plugin uses to hide the location of the file. Is there a way to change that to something else so that I can make a directory and point it to it?

After if happened I used define('MP_LARGE_DOWNLOADS', true); as a stopgap but that's not ideal. I had my host bump my var/tmp directory up to 4GB and took the line back out, and now I'm watching the var/tmp fill right back up.

Initially it was about 1,000 downloads per hour, but now it's only about 40 per hour. I thought just the initial demand filling it up was causing an error, but now that there's plenty of room there are no errors or hiccups and it's filling back up again. I also thought it was because I had payments set to sandbox (free download so it didn't make a difference to the user) but now that I have proper payment info it's still doing it.

Any ideas? My host also said I was being irresponsible by sending a 22MB file to var/tmp. If I placed the product to download on an external site would it still do the same thing?

I don't mind using define('MP_LARGE_DOWNLOADS', true); for now since it's a free download, but it's not ideal and I can't have the URL exposed when we sell the full album. Thanks.

  • PC

    Hey there,

    Greetings and thanks for posting on the forums.

    This is something which is indeed strange coz MarketPress should delete the temp file as soon as the file is downloaded. Perhaps the downloads are too high that its not getting deleted before the temp gets filled up.

    I am not 100% sure whether serving the file from another server would help as the download would still be served by MarketPress.

    I have called our lead developer @Aaron for his thoughts on this one and he should be here sooner than later.

    Cheers
    PC
    Sales &Support

  • Aaron

    I couldn't really tell you why files are sticking in temp. It's not at all MP specific, it's using the normal WP core file functions for downloading a url. And looking through those functions @unlink() is called on it, so it should be deleting the temp file.

    Temp dir is setup in your php.ini. As far a clearing it, that's a server task, usually you would setup a cron job to regularly clear out the dir.

    Note that if you can put the original file inside your uploads directory (with an unguessable filename), that is super ideal because then MP can serve it directly without first temporarily downloading it. That should solve your tmp problem and make it faster and use less RAM.

  • tunelab

    Hi @Aaron. Sorry for not replying earlier. You mention that if it's in the uploads directory it shouldn't be utilizing the var/tmp storage? My file is actually, however it was manually placed there and not in the 2013/10/XX/ folder where it would be if I had uploaded it from the backend.

    Is that a necessity? Either way, I will try temporarily increasing the upload limit and uploading the file from the Wordpress backend and see if that changes the behavior any. Thanks again for the assistance.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.