new image directory location

I realize I was the one who suggested splitting the image directories into subdirectories because of file system issues with too many files in a single directory…



But, what exactly was the splitting criteria? I think I suggested by name or number, but I just looked at my banners directory (since it is nice and small) and I’m not sure I can quite figure out how it’s being split…


[QUOTE]

root@host [/home/webunica/public_images_dev/banner]# ls -R

.:

./ …/ 0/ 1/ 2/ kitchen.jpg



./0:

./ …/ common_image_1.jpg common_image_2.gif



./1:

./ …/ banner.1357.jpg coolban.jpg fwk.jpg instcool.jpg social.jpg uninews.jpg



./2:

./ …/ cat.jpg



[/QUOTE]



Could we get some explanation to how that works?

This became one of the most ridiculous “improvements”. Instead of making it optional, for the current v.2.0.15 store owners, after the upgrade to 2.1, this destroys previously builded images file structure on the fly.

Well, it was essential for anyone with over 100,000 images in a single directory. It would be difficult to make it optional. There would probably be a slightly noticeable difference at 10-20,000 images. But they defaulted it to 1000 images per directory stored in config.php:

define(‘MAX_FILES_IN_DIR’, 1000);

Which is an issue for people who upgraded since it can only be set before installation. 1000 files in a directory isn’t an issue on any file system, and is a horrible default. 10,000 would have been a much better default, it would have only affected people who might start to notice a difference.

Because they start at 1000 by default, by the time someone reaches 1,000,000 files, they are going to have 1000 folders, which would be a bigger pain.



I’m going to have to go through each directory and fix this, sigh.



While going through the upgrade files I found in fn.images.php:

$path .= “/” . floor($image_id / MAX_FILES_IN_DIR);



So:

folder 0: 0 < $image_id < MAX_FILES_IN_DIR

folder 1: MAX_FILES_IN_DIR < $image_id < MAX_FILES_IN_DIR2

folder 2: MAX_FILES_IN_DIR
2 < $image_id < MAX_FILES_IN_DIR*3

ETC.



But I have directories up to 4 with around 8 files in each, so the image_id’s are all weird or something.





So what I need to know is:

How can I modify the upgrade files to use MAX_FILES_IN_DIR = 10000, before it moves everything around?

There’s also a section like this:


[QUOTE] if (empty($image_id)) {

$max_id = db_get_field(“SELECT MAX(image_id) FROM ?:$itable”);

$images_path .= floor($max_id / MAX_FILES_IN_DIR) . “/”;

} else {

$images_path .= floor($image_id / MAX_FILES_IN_DIR) . “/”;

}

[/QUOTE]

Which is strange, since if the $image_id is empty, the $max_id will always put it in the last folder. But if that is a precursor to adding a new image, the image will actually probably get $max_id + 1, so the last image with id = MAX_FILES_IN_DIR +1 will be in the wrong directory.

Did you found out a solution for this because a have big problem with this “fix”?