move warehouse directory creation into a single place
This commit is contained in:
		
							parent
							
								
									794eff56b4
								
							
						
					
					
						commit
						5dda40513c
					
				@ -8,7 +8,6 @@
 | 
				
			|||||||
class FlashFileHandler extends DataHandlerExtension {
 | 
					class FlashFileHandler extends DataHandlerExtension {
 | 
				
			||||||
	protected function create_thumb($hash) {
 | 
						protected function create_thumb($hash) {
 | 
				
			||||||
		// FIXME: scale image, as not all boards use 192x192
 | 
							// FIXME: scale image, as not all boards use 192x192
 | 
				
			||||||
		mkdir(dirname(warehouse_path("thumbs", $hash)), 0755, true);
 | 
					 | 
				
			||||||
		copy("ext/handle_flash/thumb.jpg", warehouse_path("thumbs", $hash));
 | 
							copy("ext/handle_flash/thumb.jpg", warehouse_path("thumbs", $hash));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -99,7 +99,6 @@ class IcoFileHandler extends SimpleExtension {
 | 
				
			|||||||
		$q = $config->get_int("thumb_quality");
 | 
							$q = $config->get_int("thumb_quality");
 | 
				
			||||||
		$mem = $config->get_int("thumb_max_memory") / 1024 / 1024; // IM takes memory in MB
 | 
							$mem = $config->get_int("thumb_max_memory") / 1024 / 1024; // IM takes memory in MB
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		mkdir(dirname($outname), 0755, true);
 | 
					 | 
				
			||||||
		if($config->get_bool("ico_convert")) {
 | 
							if($config->get_bool("ico_convert")) {
 | 
				
			||||||
			// "-limit memory $mem" broken?
 | 
								// "-limit memory $mem" broken?
 | 
				
			||||||
			exec("convert {$inname}[0] -geometry {$w}x{$h} -quality {$q} jpg:$outname");
 | 
								exec("convert {$inname}[0] -geometry {$w}x{$h} -quality {$q} jpg:$outname");
 | 
				
			||||||
 | 
				
			|||||||
@ -8,7 +8,6 @@
 | 
				
			|||||||
class MP3FileHandler extends DataHandlerExtension {
 | 
					class MP3FileHandler extends DataHandlerExtension {
 | 
				
			||||||
	protected function create_thumb($hash) {
 | 
						protected function create_thumb($hash) {
 | 
				
			||||||
		// FIXME: scale image, as not all boards use 192x192
 | 
							// FIXME: scale image, as not all boards use 192x192
 | 
				
			||||||
		mkdir(dirname(warehouse_path("thumbs", $hash)), 0755, true);
 | 
					 | 
				
			||||||
		copy("ext/handle_mp3/thumb.jpg", warehouse_path("thumbs", $hash));
 | 
							copy("ext/handle_mp3/thumb.jpg", warehouse_path("thumbs", $hash));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -41,7 +41,6 @@ class SVGFileHandler implements Extension {
 | 
				
			|||||||
//			}
 | 
					//			}
 | 
				
			||||||
//			else {
 | 
					//			else {
 | 
				
			||||||
				// FIXME: scale image, as not all boards use 192x192
 | 
									// FIXME: scale image, as not all boards use 192x192
 | 
				
			||||||
				mkdir(dirname(warehouse_path("thumbs", $hash)), 0755, true);
 | 
					 | 
				
			||||||
				copy("ext/handle_svg/thumb.jpg", warehouse_path("thumbs", $hash));
 | 
									copy("ext/handle_svg/thumb.jpg", warehouse_path("thumbs", $hash));
 | 
				
			||||||
//			}
 | 
					//			}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
@ -485,9 +485,11 @@ function format_text($string) {
 | 
				
			|||||||
	return $tfe->formatted;
 | 
						return $tfe->formatted;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function warehouse_path($base, $hash) {
 | 
					function warehouse_path($base, $hash, $create=true) {
 | 
				
			||||||
	$ab = substr($hash, 0, 2);
 | 
						$ab = substr($hash, 0, 2);
 | 
				
			||||||
	return "$base/$ab/$hash";
 | 
						$pa = "$base/$ab/$hash";
 | 
				
			||||||
 | 
						if($create && !file_exists(dirname($pa))) mkdir(dirname($pa), 0755, true);
 | 
				
			||||||
 | 
						return $pa;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
 | 
					/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
 | 
				
			||||||
 | 
				
			|||||||
@ -48,7 +48,6 @@ class PixelFileHandler extends DataHandlerExtension {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		$ok = false;
 | 
							$ok = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		mkdir(dirname($outname), 0755, true);
 | 
					 | 
				
			||||||
		switch($config->get_string("thumb_engine")) {
 | 
							switch($config->get_string("thumb_engine")) {
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
			case 'gd':
 | 
								case 'gd':
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user