lost resizes/thumbs under heavy server load while delting single image - maintenance run fails - mark dirty fails - possible fix

scuba303

Joined: 2010-06-01
Posts: 11
Posted: Fri, 2011-09-30 14:07

hey..
we are having trouble with our g3 installation under heavy load. load can be caused through visitors or editors moving stuff. now an editor deleted a single image which deleted thumbs and resizes directory from the parent album. original album stayed untouched. trying to "cure" the whole thing with mark dirty or maintenance runs failed. reason seems to be the non existing directories.
possible fix was:

system/libraries/Image.php
public function save
after
// Separate the directory and filename
$dir = pathinfo($new_image, PATHINFO_DIRNAME);
$file = pathinfo($new_image, PATHINFO_BASENAME);
add
if(file_exists($dir) === false) {
if(!mkdir($dir, 0777, true)) {
Kohana_Log::add("error",print_r("problem : couldn't create dir",1));
}
}
also i changed
// Normalize the path
$dir = str_replace('\\', '/', realpath($dir)).'/';
to
#$dir = str_replace('\\', '/', realpath($dir)).'/';
added
$dir = $dir .'/';