From 03c9562b4018ca5055c342e91d11c286ecc9fc23 Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Tue, 11 Apr 2006 05:19:56 +0000 Subject: [PATCH] Moving attachments attached to forum posts when moving threads between forums was broken when dataroot is over an nfs mount (important for clustering!)... this fixes it but please can somebody test this on windows --- mod/forum/lib.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index e46fa095da..8b26260131 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -2342,7 +2342,11 @@ function forum_move_attachments($discussion, $forumid) { if (is_dir($oldpostdir)) { $newpost = $oldpost; $newpost->forum = $forumid; - $newpostdir = forum_file_area($newpost); + $newpostdir = forum_file_area_name($newpost); + // take off the last directory because otherwise we're renaming to a directory that already exists + // and this is unhappy in certain situations, eg over an nfs mount and potentially on windows too. + make_upload_directory(substr($newpostdir,0,strrpos($newpostdir,'/'))); + $newpostdir = $CFG->dataroot.'/'.forum_file_area_name($newpost); $files = get_directory_list($oldpostdir); // get it before we rename it. if (! @rename($oldpostdir, $newpostdir)) { $return = false; -- 2.39.5