From c1f63276eecac1b2a4b524309a961f6b6aaa8307 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 7 Dec 2012 12:42:38 -0800 Subject: [PATCH] - client (unix): rename() doesn't work between filesystems. If the user has set things up so that slots/ is a symlink to a different filesystem, things won't work when the client moves output files from the slot to project dir. Solution: if rename() fails, try system("mv ...") since mv works across filesystems --- checkin_notes | 11 +++++++++++ lib/filesys.cpp | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/checkin_notes b/checkin_notes index e5276c2941..6b8d9d65ba 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7361,3 +7361,14 @@ David 7 Dec 2012 clientgui/ AsyncRPC.cpp stdwx.h + +David 7 Dec 2012 + - client (unix): rename() doesn't work between filesystems. + If the user has set things up so that slots/ is a symlink + to a different filesystem, things won't work when the client + moves output files from the slot to project dir. + Solution: if rename() fails, try system("mv ...") + since mv works across filesystems + + lib/ + filesys.cpp diff --git a/lib/filesys.cpp b/lib/filesys.cpp index 62385839d0..2c5d50eb8a 100644 --- a/lib/filesys.cpp +++ b/lib/filesys.cpp @@ -594,7 +594,15 @@ static int boinc_rename_aux(const char* old, const char* newf) { if (MoveFileExA(old, newf, MOVEFILE_REPLACE_EXISTING|MOVEFILE_WRITE_THROUGH)) return 0; return GetLastError(); #else + // rename() doesn't work between filesystems. + // So if it fails, try the "mv" command, which does work + // int retval = rename(old, newf); + if (retval) { + char buf[MAXPATHLEN+MAXPATHLEN]; + sprintf(buf, "mv \"%s\" \"%s\"", old, newf); + retval = system(buf); + } if (retval) return ERR_RENAME; return 0; #endif