浏览代码

UPD: Create separate archives - request password and volume size only once

Alexander Koblov 3 年之前
父节点
当前提交
9cdebe8103
共有 1 个文件被更改,包括 37 次插入21 次删除
  1. 37 21
      src/fpackdlg.pas

+ 37 - 21
src/fpackdlg.pas

@@ -3,7 +3,7 @@
    -------------------------------------------------------------------------
    File packing window
 
-   Copyright (C) 2007-2020 Alexander Koblov ([email protected])
+   Copyright (C) 2007-2022 Alexander Koblov ([email protected])
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -70,6 +70,9 @@ type
     FExistsArchive : Boolean;
     FSourceFileSource: IFileSource;
     FTargetFileSource:  IArchiveFileSource;
+    FPlugin: Boolean;
+    FPassword: String;
+    FVolumeSize: String;
     FCustomParams: String;
     FTargetPathInArchive: String;
     procedure SwitchOptions(ArcTypeChange: Boolean);
@@ -366,9 +369,11 @@ begin
             EnableControl(cbPutInTarFirst, not ((sCmd = 'tar') or StrBegins(sCmd, 'tar.')));
             cbCreateSeparateArchives.Checked:= False;
           end;
+        FPlugin:= True;
         // Options that supported by plugins
         EnableControl(cbStoreDir, True);
         // Options that don't supported by plugins
+        cbMultivolume.Checked:= False;
         EnableControl(cbMultivolume, False);
         Exit;
       end;
@@ -415,7 +420,7 @@ begin
             EnableControl(cbPutInTarFirst, not ((sCmd = 'tar') or StrBegins(sCmd, 'tar.')));
             cbCreateSeparateArchives.Checked:= False;
           end;
-
+          FPlugin:= False;
           // Options that don't supported by addons
           cbStoreDir.Checked:= True;
           EnableControl(cbStoreDir, False);
@@ -514,9 +519,6 @@ var
   NewTargetFileSource: IArchiveFileSource = nil;
 
   procedure Pack(var FilesToPack: TFiles; QueueId: TOperationsManagerQueueIdentifier);
-  var
-    sPassword,
-    sPasswordTmp: String;
   begin
     if Assigned(NewTargetFileSource) then
       begin
@@ -547,23 +549,9 @@ var
                 with Operation as TMultiArchiveCopyInOperation do
                 begin
                   if cbEncrypt.Checked then
-                    repeat
-                      if not InputQuery(Caption, rsMsgPasswordEnter, True, sPassword) then
-                        Exit;
-                      if gRepeatPassword then
-                        begin
-                          if not InputQuery(Caption, rsMsgPasswordVerify, True, sPasswordTmp) then
-                            Exit;
-                        end
-                      else
-                        sPasswordTmp:= sPassword;
-                      if sPassword <> sPasswordTmp then
-                        ShowMessage(rsMsgPasswordDiff)
-                      else
-                        Password:= sPassword;
-                    until sPassword = sPasswordTmp;
+                    Password:= FPassword;
                   if cbMultivolume.Checked then
-                    VolumeSize:= InputBox(Caption, rsMsgVolumeSizeEnter, EmptyStr);
+                    VolumeSize:= FVolumeSize;
                   PackingFlags := aFlags;
                   CreateNew:= FNewArchive;
                   CustomParams:= FCustomParams;
@@ -578,6 +566,7 @@ var
   end;
 
 var
+  sPassword, sPasswordTmp: String;
   QueueId: TOperationsManagerQueueIdentifier;
 begin
   if Assigned(FTargetFileSource) then
@@ -591,6 +580,33 @@ begin
   end
   else // Create a new target file source.
   begin
+    if not FPlugin then
+    begin
+      if cbEncrypt.Checked then
+      begin
+        sPassword:= EmptyStr;
+        sPasswordTmp:= EmptyStr;
+        repeat
+          if not InputQuery(Caption, rsMsgPasswordEnter, True, sPassword) then
+            Exit;
+          if gRepeatPassword then
+            begin
+              if not InputQuery(Caption, rsMsgPasswordVerify, True, sPasswordTmp) then
+                Exit;
+            end
+          else
+            sPasswordTmp:= sPassword;
+          if sPassword <> sPasswordTmp then
+            ShowMessage(rsMsgPasswordDiff)
+          else
+            FPassword:= sPassword;
+        until sPassword = sPasswordTmp;
+      end;
+
+      if cbMultivolume.Checked then
+        FVolumeSize:= InputBox(Caption, rsMsgVolumeSizeEnter, EmptyStr);
+    end;
+
     // If create separate archives, one per selected file/dir
     if cbCreateSeparateArchives.Checked then
       begin