One user folder problem (need help) One user folder problem (need help)
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

One user folder problem (need help)

Started by matonka007, January 06, 2014, 10:31:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

matonka007

I have a big problem. My hosting provider wants to block my website. Because I have a gallery of more than 30,000 photographers in one folder. I need help. The folder is / albums/userpics/10001 /

All photos are single user. How can I split the files into multiple folders? I can not have more than 1000 files in a single folder (Regulation hosting provider). Please help. Tell me that this is possible. :'(

gmc

1,000 file limit per folder? Or did you mean 10,000?
1,000 is not very Coppermine friendly... Since a single photo can easily have an original, normal,  and thumb - that is only 333 pictures per folder....

Splitting 'normal' folders isn't a big deal - but user galleries aren't 'normal' - as they tie the folder name to the user_id... I'll have to dig and see if subfolders are supported for user folders - unless one of the other devs can answer.

Just to see - I verified with my ISP - and the only limit imposed is 500,000 inodes - any combination of files, directories, mail messages, and symlinks. 
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

gmc

#2
A quick test - and while uploading a user pic doesn't give a choice of folders - I was able to take existing pics and move them to a subfolder - with corresponding update to cpg_pictures to update the filepath for those files... Of course all related (original, thumb, normal) need to move together...

The FileMove plugin allows moving from/within the userpics folder - just define the destination folders in your file system first - and I'd suggest keeping the destination to a subfolder within the original users folder...
You can download FileMove from http://sourceforge.net/projects/coppermine/files/Plugins/1.5.x/
Direct link: http://sourceforge.net/projects/coppermine/files/Plugins/1.5.x/cpg1.5.x_plugin_FileMove_v1.3.zip/download

May be other plugins suitable as well - just found that one first.

A possibility might be some kind of automated maintenance task that checks the folders (could be just   userpics - or all) - and if something is approaching the limit or over a threshold - copy contents to a subfolder and update database accordingly...  If your limit is really 10,000 - working on a threshold between 5-7K would should stop anyone from exceeding between runs... A 1,000 limit would be challenging...

Hope that helps...
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

ΑndrĂ©

Quote from: gmc on January 07, 2014, 12:12:03 AM
I'll have to dig and see if subfolders are supported for user folders - unless one of the other devs can answer.
I've added a hidden config option in cpg1.5.x some time ago for just that reason:
        // Upload pictures in a sub-directory named according to the album ID
        if ($CONFIG['upload_create_album_directory']) {
            $filepath .= '/'.$album;
            $dest_dir .= '/'.$album;
            if (!is_dir($dest_dir)) {
                mkdir($dest_dir, octdec($CONFIG['default_dir_mode']));
                if (!is_dir($dest_dir)) {
                    echo sprintf('error|'.$lang_db_input_php['err_mkdir'].'|1', $dest_dir);
                    exit;
                }
                @chmod($dest_dir, octdec($CONFIG['default_dir_mode'])); //silence the output in case chmod is disabled
                $fp = fopen($dest_dir . '/index.php', 'w');
                fwrite($fp, ' ');
                fclose($fp);
            }
        }


This code creates a sub-directory for each album in each user directory the user uploads files to. To enable that feature, you manually need to add a new database entry to the config table (name "upload_create_album_directory", value "1"). This of course applies just for new uploads, existing files need to be moved either with the plugin Greg already referred or with an automated script (which doesn't exist yet).