Fixed bug: DisableVfsForThisThread made VFS control API to fail

This commit is contained in:
Berserker 2019-05-25 20:57:47 +03:00
parent d67a8ae4f9
commit 7cb8c94406
2 changed files with 66 additions and 82 deletions

View File

@ -343,9 +343,8 @@ end;
function RunVfs (DirListingOrder: TDirListingSortType): boolean;
begin
result := not DisableVfsForThisThread;
result := true;
if result then begin
with VfsCritSection do begin
Enter;
@ -362,27 +361,23 @@ begin
Leave;
end; // .with
end; // .if
end; // .function RunVfs
function PauseVfs: LONGBOOL; stdcall;
begin
result := not DisableVfsForThisThread;
result := true;
if result then begin
with VfsCritSection do begin
Enter;
VfsIsRunning := false;
Leave;
end;
end;
end;
function ResetVfs: LONGBOOL; stdcall;
begin
result := not DisableVfsForThisThread;
result := true;
if result then begin
with VfsCritSection do begin
Enter;
VfsItems.Clear;
@ -393,7 +388,6 @@ begin
Leave;
end;
end;
end;
function IsVfsActive: boolean;
begin
@ -631,9 +625,6 @@ var
i: integer;
begin
result := not DisableVfsForThisThread;
if result then begin
with VfsCritSection do begin
Enter;
result := VfsTreeIsBuilt;
@ -661,7 +652,6 @@ begin
Leave;
end; // .with
end; // .if
end; // .function RefreshVfs
function RefreshMappedFile (const FilePath: WideString): boolean;
@ -674,9 +664,6 @@ var
begin
VfsItem := nil;
// * * * * * //
result := not DisableVfsForThisThread;
if result then begin
with VfsCritSection do begin
Enter;
result := VfsTreeIsBuilt;
@ -697,7 +684,6 @@ begin
Leave;
end; // .with
end; // .if
end; // .function RefreshMappedFile
begin

View File

@ -10,7 +10,7 @@ unit VfsWatching;
uses
Windows, SysUtils, Math,
Utils, Concur, WinUtils, StrLib, WinNative,
VfsBase, VfsUtils, {FIXME} DlgMes;
VfsBase, VfsUtils;
(* Spawns separate thread, which starts recursive monitoring for changes in specified directory.
@ -253,7 +253,6 @@ begin
if NeedFullRescan and (PlannedRescanTime <= CurrentTime) then begin
VfsBase.RefreshVfs;
NeedFullRescan := false;
VarDump(['Fully rescanned']);
end;
if DirChangesScanner = nil then begin
@ -283,7 +282,6 @@ begin
end else if DirChange.Action = NOTIFY_FILE_MODIFIED then begin
if not NeedFullRescan then begin
VfsBase.RefreshMappedFile(DirChange.FilePath);
VarDump(['Updated ' + DirChange.FilePath]);
end;
LastChangeTime := WinUtils.GetMicroTime;