pages.php: HOTFIX add copy fallback in case of already existing file when moving thread.

This commit is contained in:
Zankaria 2024-08-18 01:00:32 +02:00
parent d8c5c600a8
commit aec814266c

View file

@ -8,6 +8,13 @@ use Vichan\Functions\Net;
defined('TINYBOARD') or exit;
function _link_or_copy(string $target, string $link): bool {
if (!link($target, $link)) {
error_log("Failed to link() $target to $link. FAlling back to copy()");
return copy($target, $link);
}
return true;
}
function mod_page($title, $template, $args, $subtitle = false) {
global $config, $mod;
@ -1348,7 +1355,7 @@ function mod_move($originBoard, $postID) {
error(_('Target and source board are the same.'));
// link() if leaving a shadow thread behind; else, rename().
$clone = $shadow ? 'link' : 'rename';
$clone = $shadow ? '_link_or_copy' : 'rename';
// indicate that the post is a thread
$post['op'] = true;
@ -1641,7 +1648,7 @@ function mod_merge($originBoard, $postID) {
$op = $post;
$op['id'] = $newID;
$clone = $shadow ? 'link' : 'rename';
$clone = $shadow ? '_link_or_copy' : 'rename';
if ($post['has_file']) {
// copy image