mirror of https://github.com/BOINC/boinc.git
client: fix bug when delete > 4GB file
The function to delete a slot dir file (delete_project_owned_file()) called boinc_file_or_symlink_exists(), and returning success (with no message) if this return false. boinc_file_or_symlink_exists() incorrectly returned false for > 4GB file on Win, because it used stat(), which handles only 32 bit file size. Fix: remove the call to boinc_file_or_symlink_exists(); instead, always call DeleteFile(), and check for the ERROR_FILE_NOT_FOUND status. I'll fix the stat() problem later.
This commit is contained in:
parent
22711fef8e
commit
fa3f6be512
|
@ -231,10 +231,16 @@ int set_to_project_group(const char*) {
|
|||
}
|
||||
#endif // ! _WIN32
|
||||
|
||||
// delete a file.
|
||||
// return success if we deleted it or it didn't exist in the first place
|
||||
//
|
||||
static int delete_project_owned_file_aux(const char* path) {
|
||||
#ifdef _WIN32
|
||||
if (DeleteFile(path)) return 0;
|
||||
int error = GetLastError();
|
||||
if (error == ERROR_FILE_NOT_FOUND) {
|
||||
return 0;
|
||||
}
|
||||
if (error == ERROR_ACCESS_DENIED) {
|
||||
SetFileAttributes(path, FILE_ATTRIBUTE_NORMAL);
|
||||
if (DeleteFile(path)) return 0;
|
||||
|
@ -242,6 +248,9 @@ static int delete_project_owned_file_aux(const char* path) {
|
|||
return ERR_UNLINK;
|
||||
#else
|
||||
int retval = unlink(path);
|
||||
if (retval == ENOENT) {
|
||||
return 0;
|
||||
}
|
||||
if (retval && g_use_sandbox && (errno == EACCES)) {
|
||||
// We may not have permission to read subdirectories created by projects
|
||||
return remove_project_owned_file_or_dir(path);
|
||||
|
@ -258,9 +267,6 @@ static int delete_project_owned_file_aux(const char* path) {
|
|||
int delete_project_owned_file(const char* path, bool retry) {
|
||||
int retval = 0;
|
||||
|
||||
if (!boinc_file_or_symlink_exists(path)) {
|
||||
return 0;
|
||||
}
|
||||
retval = delete_project_owned_file_aux(path);
|
||||
if (retval && retry) {
|
||||
double start = dtime();
|
||||
|
|
Loading…
Reference in New Issue