Improve robustness when moving / merging threads
- previously this would choke on threads where the image file is missing
This commit is contained in:
parent
c10756c96f
commit
43a6a67844
|
@ -28,6 +28,12 @@ function mod_page($title, $template, $args, $subtitle = false) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clone_wrapped_with_exist_check($clonefn, $src, $dest) {
|
||||||
|
if (file_exists($src)) {
|
||||||
|
$clonefn($src, $dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function mod_login($redirect = false) {
|
function mod_login($redirect = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -1353,9 +1359,9 @@ function mod_move($originBoard, $postID) {
|
||||||
// copy image
|
// copy image
|
||||||
foreach ($post['files'] as $i => &$file) {
|
foreach ($post['files'] as $i => &$file) {
|
||||||
if ($file['file'] !== 'deleted')
|
if ($file['file'] !== 'deleted')
|
||||||
$clone($file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
clone_wrapped_with_exist_check($clone, $file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
||||||
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file')))
|
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file')))
|
||||||
$clone($file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
clone_wrapped_with_exist_check($clone, $file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1416,8 +1422,8 @@ function mod_move($originBoard, $postID) {
|
||||||
if ($post['has_file']) {
|
if ($post['has_file']) {
|
||||||
// copy image
|
// copy image
|
||||||
foreach ($post['files'] as $i => &$file) {
|
foreach ($post['files'] as $i => &$file) {
|
||||||
$clone($file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
clone_wrapped_with_exist_check($clone, $file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
||||||
$clone($file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
clone_wrapped_with_exist_check($clone, $file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// insert reply
|
// insert reply
|
||||||
|
@ -1610,9 +1616,9 @@ function mod_merge($originBoard, $postID) {
|
||||||
// copy image
|
// copy image
|
||||||
foreach ($post['files'] as $i => &$file) {
|
foreach ($post['files'] as $i => &$file) {
|
||||||
if ($file['file'] !== 'deleted')
|
if ($file['file'] !== 'deleted')
|
||||||
$clone($file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
clone_wrapped_with_exist_check($clone, $file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
||||||
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file')))
|
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file')))
|
||||||
$clone($file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
clone_wrapped_with_exist_check($clone, $file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1673,8 +1679,8 @@ function mod_merge($originBoard, $postID) {
|
||||||
if ($post['has_file']) {
|
if ($post['has_file']) {
|
||||||
// copy image
|
// copy image
|
||||||
foreach ($post['files'] as $i => &$file) {
|
foreach ($post['files'] as $i => &$file) {
|
||||||
$clone($file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
clone_wrapped_with_exist_check($clone, $file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
||||||
$clone($file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
clone_wrapped_with_exist_check($clone, $file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// insert reply
|
// insert reply
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
elseif ($action == 'rebuild') {
|
elseif ($action == 'rebuild') {
|
||||||
print_err("catalog_build calling Catalog.build 2");
|
print_err("catalog_build calling Catalog.build 2");
|
||||||
$b->build($settings, $board);
|
$b->build($settings, $board);
|
||||||
if($settings['has_overboard']) {
|
if(isset($settings['has_overboard']) && $settings['has_overboard']) {
|
||||||
$b->buildOverboardCatalog($settings, $boards);
|
$b->buildOverboardCatalog($settings, $boards);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue