[core] relax the rule for exclusive write access

* If we can't get a write handle for more than 5 seconds, retry with FILE_SHARE_WRITE
* This is a partial revert of 2f81e4f177, in order to address #924.
This commit is contained in:
Pete Batard 2017-04-09 21:05:10 +01:00
parent 2417ea7409
commit 854620d0ba
2 changed files with 9 additions and 10 deletions

View file

@ -57,7 +57,6 @@ const GUID PARTITION_SYSTEM_GUID =
* Globals
*/
RUFUS_DRIVE_INFO SelectedDrive;
extern BOOL lock_drive;
/*
* The following methods get or set the AutoMount setting (which is different from AutoRun)
@ -148,10 +147,10 @@ static HANDLE GetHandle(char* Path, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWr
break;
if (i == 0) {
uprintf("Waiting for access...");
} else if (!lock_drive && bWriteAccess && !bWriteShare && (i > (2*DRIVE_ACCESS_RETRIES)/3)) {
// If we can't seem to get a hold of the drive for a long time,
// and Alt-, is enabled, make a last ditch effort with FILE_SHARE_WRITE...
uprintf("Can't access %s - Retrying with write sharing enabled...");
} else if (bWriteAccess && !bWriteShare && (i > DRIVE_ACCESS_RETRIES/3)) {
// If we can't seem to get a hold of the drive for some time,
// try to enable FILE_SHARE_WRITE...
uprintf("Warning: Could not obtain exclusive rights. Retrying with write sharing enabled...");
bWriteShare = TRUE;
}
Sleep(DRIVE_ACCESS_TIMEOUT / DRIVE_ACCESS_RETRIES);