ElkArte Community

Project Support => Support => Topic started by: radu81 on February 02, 2016, 04:49:28 pm

Title: Attachments folder growing up fast
Post by: radu81 on February 02, 2016, 04:49:28 pm
Hi everybody,

I am having a strange problem with my attachments. One/two weeks ago my attachments were about 1GB, I installed the smush.it addon and I was able to reduce the size for about 10%. I noticed that in the next days my attachment size grow up fast, I set 2GB as limit ant that limit was reached after a couple of days. Now I have 3GB of total attachments. I set this limit to 4 GB otherwise I get the email notification that my attachments folder is full.

I don't know if this is related to smush.it addon, I also use AIR addon (attachments Image Resizing) and ILA attachments. I take a look  inside folders ( I use one folder per month) and I see a lot of small files. This month after 2 days and only a few attachments I have 492 files, 90MB. This is surely something strange.

Last days I disabled the PNG thumbnail creation (I had this set up for a few days) and I also deleted manually the thumbnails from elkarte attachments. I noticed that they get created even if this is disabled.

I really don't know how to solve this? Any idea?

(http://i.imgur.com/jTiCLPy.png) (http://i.imgur.com/P1vZaq5.png)
Title: Re: Attachments folder growing up fast
Post by: emanuele on February 02, 2016, 06:53:07 pm
I fell asleep thinking about this, that means I have to go sleep. xD
Title: Re: Attachments folder growing up fast
Post by: radu81 on February 03, 2016, 03:30:59 am
I download a copy of my ftp files and attachments are about 1.7 GB. Setting the attachments folder to 4 GB did not helped, the error I receive (attachments folder full) is because I set 2000 images per folder. Anyway this month I have about 20 attachments (about 5MB totaly) but in the folder of this month there are 1600 files, more than 90MB
Title: Re: Attachments folder growing up fast
Post by: emanuele on February 03, 2016, 04:10:42 am
The size shown in the admin panel refers to the one in the database, so most likely the addons are re-encoding the file changing the size, but not "fixing" the data before (or after) it is saved into the database (wild guess!!!). That may explain the 1.7 VS 4 GB.

About the 90 files... would you mind checking in phpmyadmin how many attachments are stored there?
Unfortunately I don't have a ready-to-use query, what I would do is find the fist message of the month and then do a:
Code: [Select]
SELECT * FROM {db_prefix}attachments WHERE id_msg > {id_first_message_of_the_month}
Title: Re: Attachments folder growing up fast
Post by: radu81 on February 03, 2016, 05:12:27 am
From phpmyadmin it seems to look correctly, but on FTP in /attachments/2016/02 I got 1900 files and a total of 9MB

I attach the export I did from phpmyadmin
Title: Re: Attachments folder growing up fast
Post by: emanuele on February 03, 2016, 05:56:42 am
Did you do any repair attachments? (Do not do it, just tell me if you run the task.)
Title: Re: Attachments folder growing up fast
Post by: radu81 on February 03, 2016, 06:07:34 am
I  did it several times in the last days
Title: Re: Attachments folder growing up fast
Post by: emanuele on February 03, 2016, 03:25:25 pm
In the attachments table there are a lot of... let's say unneeded entries (I mean those with the full path, they look like stuff introduced by the repair or something similar).

Do you have shell access on your server?
I'd like to replicate the environment, but without having to ask you for access (and download everything).
If you have ssh access, could you run the following command:
Code: [Select]
find /path/to/forum/ > file_names.txt
and download the file_names.txt file and send it to my email address? (emanuele45 gmail.com)
I'd need also the results of the query:
Code: [Select]
select id_msg, id_topic, id_board, 'none' as subject, 'empty' as body, poster_time FROM {db_prefix}messages
and the backup of the tables topics and boards.
Attachments is already up there, this should be the minimum amount of stuff needed to test the issue I think.

Is it too much of a trouble?
Title: Re: Attachments folder growing up fast
Post by: radu81 on February 03, 2016, 04:22:49 pm
I have ssh ;) I sent all you asked, thanks for your help
Title: Re: Attachments folder growing up fast
Post by: emanuele on February 03, 2016, 05:01:45 pm
Thanks, received!
I'll have a look at them as soon as possible, likely tomorrow evening... sorry. :(
Title: Re: Attachments folder growing up fast
Post by: emanuele on February 04, 2016, 05:27:18 pm
First thing I think I found is Smush.it apparently doesn't delete the ".tmp" file that it creates.
I think after:
Code: [Select]
					save_smushit_file($tempfile, $filename_withpath, $file, $response);
there should be a:
Code: [Select]
@unlink($tempfile);

What do you think @Spuds ?
Title: Re: Attachments folder growing up fast
Post by: Spuds on February 04, 2016, 06:16:49 pm
 :-[  Yup for sure I boned that one up ... I updated the repo and addon site with the update.  Thanks for the debug !
Title: Re: Attachments folder growing up fast
Post by: emanuele on February 04, 2016, 06:21:50 pm
So, @radu81 for a start you can delete all the ".tmp" files (something like http://askubuntu.com/questions/377438/how-can-i-recursively-delete-all-files-of-a-specific-extension-in-the-current-di I guess).
Title: Re: Attachments folder growing up fast
Post by: radu81 on February 05, 2016, 04:24:06 am
Here is what I did:
- uninstalled Smush.it addon 0.2
- installed Smush.it 0.3
- deleted .tmp files manually (about 650MB totaly)

The problem is that in the month of february attachments\2016\02 I still got about 2000 . elk files and in february I have about 20 attachments. What should I do next?
Title: Re: Attachments folder growing up fast
Post by: TE on February 05, 2016, 04:53:26 am
mhh, maybe that's thumbnails generated for older files inside the current directory?
Title: Re: Attachments folder growing up fast
Post by: emanuele on February 05, 2016, 05:56:39 am
Give me a little bit more time... :P

Are you running out of space on the server? (Just to understand how urgent the matter is, this month I have some time constrains (I have a pretty tough deadline for the end of the month that will make me waste few thousands euro if I miss it), so I have to plan a bit my daily activities... lol)
Title: Re: Attachments folder growing up fast
Post by: radu81 on February 05, 2016, 08:03:21 am
Quote from: TE – mhh, maybe that's thumbnails generated for older files inside the current directory?
This could have sense since I deleted manually a lot of thumbnails. I'll check this

QuoteAre you running out of space on the server? (Just to understand how urgent the matter is, this month I have some time constrains (I have a pretty tough deadline for the end of the month that will make me waste few thousands euro if I miss it), so I have to plan a bit my daily activities... lol)
Nope, the forum is running fine now, I have free space. I think the error I got was because I set 2000 files limit / folder. I set that higher and it works.

Take your time ;)