mirror of
https://github.com/CloudDelphi/Virtual-File-System
synced 2025-12-19 09:53:54 +01:00
Fixed bug: DisableVfsForThisThread made VFS control API to fail
This commit is contained in:
parent
d67a8ae4f9
commit
7cb8c94406
144
VfsBase.pas
144
VfsBase.pas
@ -343,55 +343,49 @@ end;
|
||||
|
||||
function RunVfs (DirListingOrder: TDirListingSortType): boolean;
|
||||
begin
|
||||
result := not DisableVfsForThisThread;
|
||||
result := true;
|
||||
|
||||
if result then begin
|
||||
with VfsCritSection do begin
|
||||
Enter;
|
||||
with VfsCritSection do begin
|
||||
Enter;
|
||||
|
||||
if not VfsIsRunning then begin
|
||||
if not VfsTreeIsBuilt then begin
|
||||
VfsDirListingOrder := DirListingOrder;
|
||||
BuildVfsItemsTree();
|
||||
SortVfsDirListings(DirListingOrder);
|
||||
VfsTreeIsBuilt := true;
|
||||
end;
|
||||
|
||||
VfsIsRunning := true;
|
||||
if not VfsIsRunning then begin
|
||||
if not VfsTreeIsBuilt then begin
|
||||
VfsDirListingOrder := DirListingOrder;
|
||||
BuildVfsItemsTree();
|
||||
SortVfsDirListings(DirListingOrder);
|
||||
VfsTreeIsBuilt := true;
|
||||
end;
|
||||
|
||||
VfsIsRunning := true;
|
||||
end;
|
||||
|
||||
Leave;
|
||||
end; // .with
|
||||
end; // .if
|
||||
Leave;
|
||||
end; // .with
|
||||
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;
|
||||
with VfsCritSection do begin
|
||||
Enter;
|
||||
VfsIsRunning := false;
|
||||
Leave;
|
||||
end;
|
||||
end;
|
||||
|
||||
function ResetVfs: LONGBOOL; stdcall;
|
||||
begin
|
||||
result := not DisableVfsForThisThread;
|
||||
result := true;
|
||||
|
||||
if result then begin
|
||||
with VfsCritSection do begin
|
||||
Enter;
|
||||
VfsItems.Clear;
|
||||
MappedFiles.Clear;
|
||||
Mappings.Clear;
|
||||
VfsIsRunning := false;
|
||||
VfsTreeIsBuilt := false;
|
||||
Leave;
|
||||
end;
|
||||
with VfsCritSection do begin
|
||||
Enter;
|
||||
VfsItems.Clear;
|
||||
MappedFiles.Clear;
|
||||
Mappings.Clear;
|
||||
VfsIsRunning := false;
|
||||
VfsTreeIsBuilt := false;
|
||||
Leave;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -631,37 +625,33 @@ var
|
||||
i: integer;
|
||||
|
||||
begin
|
||||
result := not DisableVfsForThisThread;
|
||||
with VfsCritSection do begin
|
||||
Enter;
|
||||
result := VfsTreeIsBuilt;
|
||||
|
||||
if result then begin
|
||||
with VfsCritSection do begin
|
||||
Enter;
|
||||
result := VfsTreeIsBuilt;
|
||||
if result then begin
|
||||
VfsItems.Clear;
|
||||
MappedFiles.Clear;
|
||||
VfsWasRunning := VfsIsRunning;
|
||||
VfsIsRunning := false;
|
||||
VfsTreeIsBuilt := false;
|
||||
|
||||
if result then begin
|
||||
VfsItems.Clear;
|
||||
MappedFiles.Clear;
|
||||
VfsWasRunning := VfsIsRunning;
|
||||
VfsIsRunning := false;
|
||||
VfsTreeIsBuilt := false;
|
||||
|
||||
for i := 0 to Mappings.Count - 1 do begin
|
||||
with TMapping(Mappings[i]) do begin
|
||||
MapDir(AbsVirtPath, AbsRealPath, OverwriteExisting, Flags);
|
||||
end;
|
||||
end;
|
||||
|
||||
if VfsWasRunning then begin
|
||||
BuildVfsItemsTree();
|
||||
SortVfsDirListings(VfsDirListingOrder);
|
||||
VfsTreeIsBuilt := true;
|
||||
VfsIsRunning := true;
|
||||
for i := 0 to Mappings.Count - 1 do begin
|
||||
with TMapping(Mappings[i]) do begin
|
||||
MapDir(AbsVirtPath, AbsRealPath, OverwriteExisting, Flags);
|
||||
end;
|
||||
end;
|
||||
|
||||
Leave;
|
||||
end; // .with
|
||||
end; // .if
|
||||
if VfsWasRunning then begin
|
||||
BuildVfsItemsTree();
|
||||
SortVfsDirListings(VfsDirListingOrder);
|
||||
VfsTreeIsBuilt := true;
|
||||
VfsIsRunning := true;
|
||||
end;
|
||||
end;
|
||||
|
||||
Leave;
|
||||
end; // .with
|
||||
end; // .function RefreshVfs
|
||||
|
||||
function RefreshMappedFile (const FilePath: WideString): boolean;
|
||||
@ -674,30 +664,26 @@ var
|
||||
begin
|
||||
VfsItem := nil;
|
||||
// * * * * * //
|
||||
result := not DisableVfsForThisThread;
|
||||
with VfsCritSection do begin
|
||||
Enter;
|
||||
result := VfsTreeIsBuilt;
|
||||
|
||||
if result then begin
|
||||
with VfsCritSection do begin
|
||||
Enter;
|
||||
result := VfsTreeIsBuilt;
|
||||
if result then begin
|
||||
VfsWasRunning := VfsIsRunning;
|
||||
VfsIsRunning := false;
|
||||
AbsRealPath := NormalizePath(FilePath);
|
||||
VfsItem := TVfsItem(MappedFiles[WideStrToCaselessKey(AbsRealPath)]);
|
||||
result := (VfsItem <> nil) and GetFileInfo(AbsRealPath, FileInfo);
|
||||
|
||||
if result then begin
|
||||
VfsWasRunning := VfsIsRunning;
|
||||
VfsIsRunning := false;
|
||||
AbsRealPath := NormalizePath(FilePath);
|
||||
VfsItem := TVfsItem(MappedFiles[WideStrToCaselessKey(AbsRealPath)]);
|
||||
result := (VfsItem <> nil) and GetFileInfo(AbsRealPath, FileInfo);
|
||||
|
||||
if result then begin
|
||||
CopyFileInfoWithoutNames(FileInfo.Base, VfsItem.Info.Base);
|
||||
end;
|
||||
|
||||
VfsIsRunning := VfsWasRunning;
|
||||
CopyFileInfoWithoutNames(FileInfo.Base, VfsItem.Info.Base);
|
||||
end;
|
||||
|
||||
Leave;
|
||||
end; // .with
|
||||
end; // .if
|
||||
VfsIsRunning := VfsWasRunning;
|
||||
end;
|
||||
|
||||
Leave;
|
||||
end; // .with
|
||||
end; // .function RefreshMappedFile
|
||||
|
||||
begin
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user