1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-01-31 12:23:48 +01:00

Make deletePost more tolerant of errors

Sometimes thumbnail generation fails but the post is still there, sometimes post deletion is aborted halfway through

Ignore errors from file_unlink and don't fail if $f->file, $f->thumb not set
This commit is contained in:
8chan 2014-11-12 21:06:58 -08:00
parent 47aa1a520d
commit 4f2398f7b8

View File

@ -1091,9 +1091,9 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) {
if (!$post['thread']) {
// Delete thread HTML page
file_unlink($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['id']));
file_unlink($board['dir'] . $config['dir']['res'] . sprintf($config['file_page50'], $post['id']));
file_unlink($board['dir'] . $config['dir']['res'] . sprintf('%d.json', $post['id']));
@file_unlink($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['id']));
@file_unlink($board['dir'] . $config['dir']['res'] . sprintf($config['file_page50'], $post['id']));
@file_unlink($board['dir'] . $config['dir']['res'] . sprintf('%d.json', $post['id']));
$antispam_query = prepare('DELETE FROM ``antispam`` WHERE `board` = :board AND `thread` = :thread');
$antispam_query->bindValue(':board', $board['uri']);
@ -1106,9 +1106,9 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) {
if ($post['files']) {
// Delete file
foreach (json_decode($post['files']) as $i => $f) {
if ($f->file !== 'deleted') {
file_unlink($config['dir']['img_root'] . $board['dir'] . $config['dir']['img'] . $f->file);
file_unlink($config['dir']['img_root'] . $board['dir'] . $config['dir']['thumb'] . $f->thumb);
if (isset($f->file, $f->thumb) && $f->file !== 'deleted') {
@file_unlink($config['dir']['img_root'] . $board['dir'] . $config['dir']['img'] . $f->file);
@file_unlink($config['dir']['img_root'] . $board['dir'] . $config['dir']['thumb'] . $f->thumb);
}
}
}