소스 검색

Trigger IO error only after exhausting attempts

Tom Dobbelaere 7 년 전
부모
커밋
a4fae0e5e3
1개의 변경된 파일7개의 추가작업 그리고 4개의 파일을 삭제
  1. 7 4
      drivers/windows/file_access_windows.cpp

+ 7 - 4
drivers/windows/file_access_windows.cpp

@@ -139,19 +139,22 @@ void FileAccessWindows::close() {
 				//atomic replace for existing file
 				//atomic replace for existing file
 				rename_error = !ReplaceFileW(save_path.c_str(), (save_path + ".tmp").c_str(), NULL, 2 | 4, NULL, NULL);
 				rename_error = !ReplaceFileW(save_path.c_str(), (save_path + ".tmp").c_str(), NULL, 2 | 4, NULL, NULL);
 			}
 			}
-			if (rename_error && close_fail_notify) {
-				close_fail_notify(save_path);
-			}
 			if (rename_error) {
 			if (rename_error) {
 				attempts--;
 				attempts--;
 				OS::get_singleton()->delay_usec(1000000); //wait 100msec and try again
 				OS::get_singleton()->delay_usec(1000000); //wait 100msec and try again
 			}
 			}
 		}
 		}
 
 
-		save_path = "";
 		if (rename_error) {
 		if (rename_error) {
+			if (close_fail_notify) {
+				close_fail_notify(save_path);
+			}
+
 			ERR_EXPLAIN("Safe save failed. This may be a permissions problem, but also may happen because you are running a paranoid antivirus. If this is the case, please switch to Windows Defender or disable the 'safe save' option in editor settings. This makes it work, but increases the risk of file corruption in a crash.");
 			ERR_EXPLAIN("Safe save failed. This may be a permissions problem, but also may happen because you are running a paranoid antivirus. If this is the case, please switch to Windows Defender or disable the 'safe save' option in editor settings. This makes it work, but increases the risk of file corruption in a crash.");
 		}
 		}
+
+		save_path = "";
+
 		ERR_FAIL_COND(rename_error);
 		ERR_FAIL_COND(rename_error);
 	}
 	}
 }
 }