Skip to content

Commit

Permalink
fix current dir locking
Browse files Browse the repository at this point in the history
  • Loading branch information
digao-dalpiaz committed Feb 1, 2021
1 parent ab051a4 commit 0ac1b6e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions UFrmUnzip.pas
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ procedure TFrmUnzip.Execute;
Z: TZipFile;
ZFile, ZFileNormalized, ZPath: string;
begin
AppDir := ExtractFilePath(Application.ExeName);
ChDir(AppDir);

Dir := GetEnvironmentVariable('UPD_PATH');

if Dir.IsEmpty then
Expand All @@ -54,7 +57,7 @@ procedure TFrmUnzip.Execute;
if not DirectoryExists(Dir) then
raise Exception.Create('Component directory does not exist');

BkpDir := ExcludeTrailingPathDelimiter(Dir)+'_'+FormatDateTime('yyyymmdd-hhnnss', Now);
BkpDir := ExcludeTrailingPathDelimiter(Dir)+'_bkp-'+FormatDateTime('yyyymmdd-hhnnss', Now);

I := 5;
while not System.SysUtils.RenameFile(Dir, BkpDir) do
Expand All @@ -68,7 +71,7 @@ procedure TFrmUnzip.Execute;

Z := TZipFile.Create;
try
Z.Open(TPath.Combine(ExtractFilePath(Application.ExeName), 'data.zip'), zmRead);
Z.Open(TPath.Combine(AppDir, 'data.zip'), zmRead);

for ZFile in Z.FileNames do
begin
Expand Down

0 comments on commit 0ac1b6e

Please sign in to comment.