SMFHacks.com

Downloads System Pro => Support => Topic started by: davejo on December 25, 2020, 04:50:43 am

Title: $folderid = floor
Post by: davejo on December 25, 2020, 04:50:43 am
Hi and Merry Christmas.

I am a little confused. A couple of weeks ago I changed the
Code: [Select]
$folderid = floor from 1000 to 380. The properties of the folder now show the folder is 383MB but it hasn't created a new folder yet.

Should I have put a '0' in front of the 380? Also where in the database is the info stored showing which folder is currently used?

The reason I ask is because I want to eliminate the folder from the regular backup file (this runs 3 times a week) so as to reduce the size of the backup. I have XCloner installed and in the config you can opt out of certain folders, which I have already done with the 'Attachments' folder and the others in the downloads folder.

[attach=1]
Title: Re: $folderid = floor
Post by: SMFHacks on December 25, 2020, 07:50:43 am
Can you attach the file you changed. I want to see the line of code you changed plus the code around it.
Title: Re: $folderid = floor
Post by: davejo on December 25, 2020, 09:19:20 am
Thanks for the reply.

Here's the file.

I would be grateful if you can modify that one, if you need to, as I have modified it to allow 8 previews rather than the default 4

Thank you
Title: Re: $folderid = floor
Post by: SMFHacks on December 25, 2020, 10:44:10 am
the 1000 or 380 is the number of files before it creates another folder. So in your case requires 380 files before making the next folder
Title: Re: $folderid = floor
Post by: davejo on December 25, 2020, 11:04:24 am
Ah ok, I thought it was MB....that's where I was going wrong.

Checking the folder and it says there are 6125 files in the folder.

So even if I left it too 1000 it should have changed it a long time ago.

Thanks again for the reply, especially on Chritsmas day.
Title: Re: $folderid = floor
Post by: SMFHacks on December 25, 2020, 08:33:35 pm
Did you have the setting "Enable multiple folders for downloads storage" enabled?
Title: Re: $folderid = floor
Post by: davejo on December 26, 2020, 01:39:42 am
Hi yes it is enabled and has been enabled all the time. You might see from the first image posted that there are other folders, so it has worked in the past just don't know why it isn't now.

I know this is a stretch but is it possible that the folder size could be included in the 'Settings' page of the mod?

Title: Re: $folderid = floor
Post by: davejo on December 26, 2020, 05:52:28 am
OK I have found out what the issue is. After creating a test site and installing the mod I changed the folder limit to 5 then added 6 'Upload File' posts which did change the folder from 0 to 1.

After that I added 6 'Upload Url:' posts which did not change the folder to 2 which is what I expected to happen because of the image files that are added with it.

Therefore if you predominantly only post url links with photos then the 'Downloads' does not add the images to the download count.

This means that if you only add links to your downloads you will never change the storage folder which, as I have shown can total up to over 6k of photos which can add up to a lot of MBs in storage space.

So now I have to think again about how to resolve this.

Is it possible to manually change the folder via the database, although as I mentioned in my first post I can't see where the data for the folder is stored...maybe I didn't look hard enough.

Any ideas are welcome  ;D
Title: Re: $folderid = floor
Post by: SMFHacks on December 26, 2020, 12:45:52 pm
Changing it in the database does not affect much since it is caculated each time.

You could modify
Code: [Select]
function Downloads_ComputeNextFolderID($ID_FILE)
{
global $modSettings;

$folderid = floor($ID_FILE / 380);

// If the current folder ID does not match the new folder ID update the settings
if ($modSettings['down_folder_id'] != $folderid)
updateSettings(array('down_folder_id' => $folderid));

}
To hard code a specific folder.
 And maybe do the folder size calc with a little bit of work https://gist.github.com/eusonlito/5099936
Title: Re: $folderid = floor
Post by: davejo on December 26, 2020, 04:22:00 pm
Thanks for the help.

What I did is to make folder limit 2 and then make 3 posts to create the new folder.

The limit can stay as 2 as no one ever uploads files to the site anyway only links photos.

That way when the size of the folder gets too big again all I have to do is post another 3 files to get a new folder.