Browse Source

ADD: Capability to execute test arсhive operation in the queue

Alexander Koblov 4 years ago
parent
commit
1baac8196f

+ 17 - 12
src/filesources/uarchivefilesourceutil.pas

@@ -9,7 +9,8 @@ uses
  uFileView,
  uFile,
  uArchiveFileSource,
- uFileSource;
+ uFileSource,
+ uOperationsManager;
 
 function GetArchiveFileSource(SourceFileSource: IFileSource;
                               ArchiveFile: TFile;
@@ -17,7 +18,8 @@ function GetArchiveFileSource(SourceFileSource: IFileSource;
                               ArchiveSign: Boolean;
                               IncludeHidden: Boolean): IArchiveFileSource;
 
-procedure TestArchive(aFileView: TFileView; aFiles: TFiles);
+procedure TestArchive(aFileView: TFileView; aFiles: TFiles;
+                              QueueIdentifier: TOperationsManagerQueueIdentifier);
 
 function FileIsArchive(const FileName: String): Boolean;
 
@@ -30,15 +32,13 @@ uses
   uFindEx,
   uShowMsg,
   uLng,
-  DCStrUtils,
   uFileSourceProperty,
   uWcxArchiveFileSource,
   uMultiArchiveFileSource,
   uFileSystemFileSource,
   uTempFileSystemFileSource,
   uFileSourceOperation,
-  uFileSourceOperationTypes,
-  uOperationsManager;
+  uFileSourceOperationTypes;
 
 // Only for direct access file sources.
 function GetArchiveFileSourceDirect(SourceFileSource: IFileSource;
@@ -163,12 +163,14 @@ begin
   end;
 end;
 
-procedure TestArchive(aFileView: TFileView; aFiles: TFiles);
+procedure TestArchive(aFileView: TFileView; aFiles: TFiles;
+  QueueIdentifier: TOperationsManagerQueueIdentifier);
 var
   I: Integer;
   FilesToTest: TFiles = nil;
   Operation: TFileSourceOperation = nil;
   ArchiveFileSource: IArchiveFileSource;
+  QueueId: TOperationsManagerQueueIdentifier;
 begin
   try
     // if in archive
@@ -182,7 +184,7 @@ begin
            if Assigned(Operation) then
              begin
                // Start operation.
-               OperationsManager.AddOperation(Operation);
+               OperationsManager.AddOperation(Operation, QueueIdentifier, False, True);
              end
            else
              msgWarning(rsMsgNotImplemented);
@@ -194,6 +196,12 @@ begin
       // if filesystem
       if aFileView.FileSource.IsClass(TFileSystemFileSource) then
         begin
+         // If archives count > 1 then put to queue
+         if (aFiles.Count > 1) and (QueueIdentifier = FreeOperationsQueueId) then
+           QueueId := OperationsManager.GetNewQueueIdentifier
+         else begin
+           QueueId := QueueIdentifier;
+         end;
           for I := 0 to aFiles.Count - 1 do // test all selected archives
             try
               // Check if there is a ArchiveFileSource for possible archive.
@@ -215,21 +223,18 @@ begin
                         if Assigned(Operation) then
                           begin
                             // Start operation.
-                            OperationsManager.AddOperation(Operation);
+                            OperationsManager.AddOperation(Operation, QueueId, False, True);
                           end
                         else
                           msgWarning(rsMsgNotImplemented);
 
                       finally
-                        if Assigned(FilesToTest) then
-                          FreeAndNil(FilesToTest);
+                        FreeAndNil(FilesToTest);
                       end;
                     end
                   else
                     msgWarning(rsMsgErrNotSupported);
               end;
-              // Short pause, so that all operations are not spawned at once.
-              Sleep(100);
             except
               on E: Exception do msgError(E.Message + LineEnding + aFiles[i].FullPath);
             end; // for

+ 11 - 0
src/frames/foptionsfileoperations.lfm

@@ -168,6 +168,17 @@ inherited frmOptionsFileOperations: TfrmOptionsFileOperations
       Caption = 'Verify checksum operation'
       TabOrder = 9
     end
+    object cbTestArchiveConfirmation: TCheckBox
+      AnchorSideLeft.Control = cbVerifyChecksumConfirmation
+      AnchorSideTop.Control = cbVerifyChecksumConfirmation
+      AnchorSideTop.Side = asrBottom
+      Left = 10
+      Height = 23
+      Top = 323
+      Width = 161
+      Caption = 'Test archive operation'
+      TabOrder = 10
+    end
   end
   object gbExecutingOperations: TGroupBox[1]
     AnchorSideLeft.Control = Owner

+ 22 - 21
src/frames/foptionsfileoperations.lrj

@@ -1,21 +1,22 @@
-{"version":1,"strings":[
-{"hash":51162117,"name":"tfrmoptionsfileoperations.gbuserinterface.caption","sourcebytes":[85,115,101,114,32,105,110,116,101,114,102,97,99,101],"value":"User interface"},
-{"hash":84721614,"name":"tfrmoptionsfileoperations.lblprogresskind.caption","sourcebytes":[83,104,111,119,32,111,112,101,114,97,116,105,111,110,115,32,112,114,111,103,114,101,115,115,32,38,105,110,105,116,105,97,108,108,121,32,105,110],"value":"Show operations progress &initially in"},
-{"hash":232270583,"name":"tfrmoptionsfileoperations.cbdropreadonlyflag.caption","sourcebytes":[68,38,114,111,112,32,114,101,97,100,111,110,108,121,32,102,108,97,103],"value":"D&rop readonly flag"},
-{"hash":36207847,"name":"tfrmoptionsfileoperations.cbrenameselonlyname.caption","sourcebytes":[83,101,108,101,99,116,32,38,102,105,108,101,32,110,97,109,101,32,119,105,116,104,111,117,116,32,101,120,116,101,110,115,105,111,110,32,119,104,101,110,32,114,101,110,97,109,105,110,103],"value":"Select &file name without extension when renaming"},
-{"hash":110955351,"name":"tfrmoptionsfileoperations.cbshowcopytabselectpanel.caption","sourcebytes":[83,104,111,38,119,32,116,97,98,32,115,101,108,101,99,116,32,112,97,110,101,108,32,105,110,32,99,111,112,121,47,109,111,118,101,32,100,105,97,108,111,103],"value":"Sho&w tab select panel in copy/move dialog"},
-{"hash":17379641,"name":"tfrmoptionsfileoperations.cbdeletetotrash.caption","sourcebytes":[68,101,108,101,38,116,101,32,116,111,32,114,101,99,121,99,108,101,32,98,105,110,32,40,83,104,105,102,116,32,107,101,121,32,114,101,118,101,114,115,101,115,32,116,104,105,115,32,115,101,116,116,105,110,103,41],"value":"Dele&te to recycle bin (Shift key reverses this setting)"},
-{"hash":240358494,"name":"tfrmoptionsfileoperations.cbcopyconfirmation.caption","sourcebytes":[67,111,112,38,121,32,111,112,101,114,97,116,105,111,110],"value":"Cop&y operation"},
-{"hash":173011838,"name":"tfrmoptionsfileoperations.cbmoveconfirmation.caption","sourcebytes":[38,77,111,118,101,32,111,112,101,114,97,116,105,111,110],"value":"&Move operation"},
-{"hash":357918,"name":"tfrmoptionsfileoperations.cbdeleteconfirmation.caption","sourcebytes":[38,68,101,108,101,116,101,32,111,112,101,114,97,116,105,111,110],"value":"&Delete operation"},
-{"hash":258035118,"name":"tfrmoptionsfileoperations.cbdeletetotrashconfirmation.caption","sourcebytes":[68,38,101,108,101,116,101,32,116,111,32,116,114,97,115,104,32,111,112,101,114,97,116,105,111,110],"value":"D&elete to trash operation"},
-{"hash":151930842,"name":"tfrmoptionsfileoperations.bvlconfirmations.caption","sourcebytes":[83,104,111,119,32,99,111,110,102,105,114,109,97,116,105,111,110,32,119,105,110,100,111,119,32,102,111,114,58],"value":"Show confirmation window for:"},
-{"hash":207724030,"name":"tfrmoptionsfileoperations.cbverifychecksumconfirmation.caption","sourcebytes":[86,101,114,105,102,121,32,99,104,101,99,107,115,117,109,32,111,112,101,114,97,116,105,111,110],"value":"Verify checksum operation"},
-{"hash":44527315,"name":"tfrmoptionsfileoperations.gbexecutingoperations.caption","sourcebytes":[69,120,101,99,117,116,105,110,103,32,111,112,101,114,97,116,105,111,110,115],"value":"Executing operations"},
-{"hash":209010058,"name":"tfrmoptionsfileoperations.lblbuffersize.caption","sourcebytes":[38,66,117,102,102,101,114,32,115,105,122,101,32,102,111,114,32,102,105,108,101,32,111,112,101,114,97,116,105,111,110,115,32,40,105,110,32,75,66,41,58],"value":"&Buffer size for file operations (in KB):"},
-{"hash":163951274,"name":"tfrmoptionsfileoperations.lblwipepassnumber.caption","sourcebytes":[38,78,117,109,98,101,114,32,111,102,32,119,105,112,101,32,112,97,115,115,101,115,58],"value":"&Number of wipe passes:"},
-{"hash":208299555,"name":"tfrmoptionsfileoperations.cbprocesscomments.caption","sourcebytes":[38,80,114,111,99,101,115,115,32,99,111,109,109,101,110,116,115,32,119,105,116,104,32,102,105,108,101,115,47,102,111,108,100,101,114,115],"value":"&Process comments with files/folders"},
-{"hash":138955607,"name":"tfrmoptionsfileoperations.cbskipfileoperror.caption","sourcebytes":[83,38,107,105,112,32,102,105,108,101,32,111,112,101,114,97,116,105,111,110,115,32,101,114,114,111,114,115,32,97,110,100,32,119,114,105,116,101,32,116,104,101,109,32,116,111,32,108,111,103,32,119,105,110,100,111,119],"value":"S&kip file operations errors and write them to log window"},
-{"hash":218727434,"name":"tfrmoptionsfileoperations.lbltypeofduplicatedrename.caption","sourcebytes":[68,117,112,108,105,99,97,116,101,100,32,110,97,109,101,32,97,117,116,111,45,114,101,110,97,109,101,32,115,116,121,108,101,58],"value":"Duplicated name auto-rename style:"},
-{"hash":108031066,"name":"tfrmoptionsfileoperations.lblhashbuffersize.caption","sourcebytes":[66,117,102,102,101,114,32,115,105,122,101,32,102,111,114,32,38,104,97,115,104,32,99,97,108,99,117,108,97,116,105,111,110,32,40,105,110,32,75,66,41,58],"value":"Buffer size for &hash calculation (in KB):"}
-]}
+{"version":1,"strings":[
+{"hash":51162117,"name":"tfrmoptionsfileoperations.gbuserinterface.caption","sourcebytes":[85,115,101,114,32,105,110,116,101,114,102,97,99,101],"value":"User interface"},
+{"hash":84721614,"name":"tfrmoptionsfileoperations.lblprogresskind.caption","sourcebytes":[83,104,111,119,32,111,112,101,114,97,116,105,111,110,115,32,112,114,111,103,114,101,115,115,32,38,105,110,105,116,105,97,108,108,121,32,105,110],"value":"Show operations progress &initially in"},
+{"hash":232270583,"name":"tfrmoptionsfileoperations.cbdropreadonlyflag.caption","sourcebytes":[68,38,114,111,112,32,114,101,97,100,111,110,108,121,32,102,108,97,103],"value":"D&rop readonly flag"},
+{"hash":36207847,"name":"tfrmoptionsfileoperations.cbrenameselonlyname.caption","sourcebytes":[83,101,108,101,99,116,32,38,102,105,108,101,32,110,97,109,101,32,119,105,116,104,111,117,116,32,101,120,116,101,110,115,105,111,110,32,119,104,101,110,32,114,101,110,97,109,105,110,103],"value":"Select &file name without extension when renaming"},
+{"hash":110955351,"name":"tfrmoptionsfileoperations.cbshowcopytabselectpanel.caption","sourcebytes":[83,104,111,38,119,32,116,97,98,32,115,101,108,101,99,116,32,112,97,110,101,108,32,105,110,32,99,111,112,121,47,109,111,118,101,32,100,105,97,108,111,103],"value":"Sho&w tab select panel in copy/move dialog"},
+{"hash":17379641,"name":"tfrmoptionsfileoperations.cbdeletetotrash.caption","sourcebytes":[68,101,108,101,38,116,101,32,116,111,32,114,101,99,121,99,108,101,32,98,105,110,32,40,83,104,105,102,116,32,107,101,121,32,114,101,118,101,114,115,101,115,32,116,104,105,115,32,115,101,116,116,105,110,103,41],"value":"Dele&te to recycle bin (Shift key reverses this setting)"},
+{"hash":240358494,"name":"tfrmoptionsfileoperations.cbcopyconfirmation.caption","sourcebytes":[67,111,112,38,121,32,111,112,101,114,97,116,105,111,110],"value":"Cop&y operation"},
+{"hash":173011838,"name":"tfrmoptionsfileoperations.cbmoveconfirmation.caption","sourcebytes":[38,77,111,118,101,32,111,112,101,114,97,116,105,111,110],"value":"&Move operation"},
+{"hash":357918,"name":"tfrmoptionsfileoperations.cbdeleteconfirmation.caption","sourcebytes":[38,68,101,108,101,116,101,32,111,112,101,114,97,116,105,111,110],"value":"&Delete operation"},
+{"hash":258035118,"name":"tfrmoptionsfileoperations.cbdeletetotrashconfirmation.caption","sourcebytes":[68,38,101,108,101,116,101,32,116,111,32,116,114,97,115,104,32,111,112,101,114,97,116,105,111,110],"value":"D&elete to trash operation"},
+{"hash":151930842,"name":"tfrmoptionsfileoperations.bvlconfirmations.caption","sourcebytes":[83,104,111,119,32,99,111,110,102,105,114,109,97,116,105,111,110,32,119,105,110,100,111,119,32,102,111,114,58],"value":"Show confirmation window for:"},
+{"hash":207724030,"name":"tfrmoptionsfileoperations.cbverifychecksumconfirmation.caption","sourcebytes":[86,101,114,105,102,121,32,99,104,101,99,107,115,117,109,32,111,112,101,114,97,116,105,111,110],"value":"Verify checksum operation"},
+{"hash":170065262,"name":"tfrmoptionsfileoperations.cbtestarchiveconfirmation.caption","sourcebytes":[84,101,115,116,32,97,114,99,104,105,118,101,32,111,112,101,114,97,116,105,111,110],"value":"Test archive operation"},
+{"hash":44527315,"name":"tfrmoptionsfileoperations.gbexecutingoperations.caption","sourcebytes":[69,120,101,99,117,116,105,110,103,32,111,112,101,114,97,116,105,111,110,115],"value":"Executing operations"},
+{"hash":209010058,"name":"tfrmoptionsfileoperations.lblbuffersize.caption","sourcebytes":[38,66,117,102,102,101,114,32,115,105,122,101,32,102,111,114,32,102,105,108,101,32,111,112,101,114,97,116,105,111,110,115,32,40,105,110,32,75,66,41,58],"value":"&Buffer size for file operations (in KB):"},
+{"hash":163951274,"name":"tfrmoptionsfileoperations.lblwipepassnumber.caption","sourcebytes":[38,78,117,109,98,101,114,32,111,102,32,119,105,112,101,32,112,97,115,115,101,115,58],"value":"&Number of wipe passes:"},
+{"hash":208299555,"name":"tfrmoptionsfileoperations.cbprocesscomments.caption","sourcebytes":[38,80,114,111,99,101,115,115,32,99,111,109,109,101,110,116,115,32,119,105,116,104,32,102,105,108,101,115,47,102,111,108,100,101,114,115],"value":"&Process comments with files/folders"},
+{"hash":138955607,"name":"tfrmoptionsfileoperations.cbskipfileoperror.caption","sourcebytes":[83,38,107,105,112,32,102,105,108,101,32,111,112,101,114,97,116,105,111,110,115,32,101,114,114,111,114,115,32,97,110,100,32,119,114,105,116,101,32,116,104,101,109,32,116,111,32,108,111,103,32,119,105,110,100,111,119],"value":"S&kip file operations errors and write them to log window"},
+{"hash":218727434,"name":"tfrmoptionsfileoperations.lbltypeofduplicatedrename.caption","sourcebytes":[68,117,112,108,105,99,97,116,101,100,32,110,97,109,101,32,97,117,116,111,45,114,101,110,97,109,101,32,115,116,121,108,101,58],"value":"Duplicated name auto-rename style:"},
+{"hash":108031066,"name":"tfrmoptionsfileoperations.lblhashbuffersize.caption","sourcebytes":[66,117,102,102,101,114,32,115,105,122,101,32,102,111,114,32,38,104,97,115,104,32,99,97,108,99,117,108,97,116,105,111,110,32,40,105,110,32,75,66,41,58],"value":"Buffer size for &hash calculation (in KB):"}
+]}

+ 5 - 1
src/frames/foptionsfileoperations.pas

@@ -3,7 +3,7 @@
    -------------------------------------------------------------------------
    File operations options page
 
-   Copyright (C) 2006-2018 Alexander Koblov ([email protected])
+   Copyright (C) 2006-2021 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
@@ -47,6 +47,7 @@ type
     cbDeleteConfirmation: TCheckBox;
     cbDeleteToTrashConfirmation: TCheckBox;
     cbVerifyChecksumConfirmation: TCheckBox;
+    cbTestArchiveConfirmation: TCheckBox;
     cmbTypeOfDuplicatedRename: TComboBoxAutoWidth;
     edtBufferSize: TEdit;
     edtHashBufferSize: TEdit;
@@ -131,6 +132,7 @@ begin
   cbCopyConfirmation.Checked           := focCopy in gFileOperationsConfirmations;
   cbMoveConfirmation.Checked           := focMove in gFileOperationsConfirmations;
   cbDeleteConfirmation.Checked         := focDelete in gFileOperationsConfirmations;
+  cbTestArchiveConfirmation.Checked    := focTestArchive in gFileOperationsConfirmations;
   cbDeleteToTrashConfirmation.Checked  := focDeleteToTrash in gFileOperationsConfirmations;
   cbVerifyChecksumConfirmation.Checked := focVerifyChecksum in gFileOperationsConfirmations;
   cmbTypeOfDuplicatedRename.ItemIndex  := Integer(gTypeOfDuplicatedRename);
@@ -165,6 +167,8 @@ begin
     Include(gFileOperationsConfirmations, focMove);
   if cbDeleteConfirmation.Checked then
     Include(gFileOperationsConfirmations, focDelete);
+  if cbTestArchiveConfirmation.Checked then
+    Include(gFileOperationsConfirmations, focTestArchive);
   if cbDeleteToTrashConfirmation.Checked then
     Include(gFileOperationsConfirmations, focDeleteToTrash);
   if cbVerifyChecksumConfirmation.Checked then

+ 1 - 1
src/uglobs.pas

@@ -89,7 +89,7 @@ type
   { How initially progress is shown for file operations }
   TFileOperationsProgressKind = (fopkSeparateWindow, fopkSeparateWindowMinimized, fopkOperationsPanel);
   { Operations with confirmation }
-  TFileOperationsConfirmation = (focCopy, focMove, focDelete, focDeleteToTrash, focVerifyChecksum);
+  TFileOperationsConfirmation = (focCopy, focMove, focDelete, focDeleteToTrash, focVerifyChecksum, focTestArchive);
   TFileOperationsConfirmations = set of TFileOperationsConfirmation;
 
   { Multi-Rename }

+ 1 - 0
src/ulng.pas

@@ -49,6 +49,7 @@ resourcestring
   rsMsgNewFile = 'New file';
   rsMsgDelFlDr = 'Delete %d selected files/directories?';
   rsMsgDelSel = 'Delete selected "%s"?';
+  rsMsgTestArchive = 'Do you want to test selected archives?';
   rsMsgVerifyChecksum = 'Do you want to verify selected checksums?';
   rsMsgObjectNotExists = 'Object does not exist!';
   // 12.05.2009 - another message, when deleting to trash

+ 25 - 5
src/umaincommands.pas

@@ -1326,16 +1326,36 @@ end;
 
 procedure TMainCommands.cm_TestArchive(const Params: array of string);
 var
+  Param: String;
+  BoolValue: Boolean;
   SelectedFiles: TFiles;
+  bConfirmation, HasConfirmationParam: Boolean;
+  QueueId: TOperationsManagerQueueIdentifier = FreeOperationsQueueId;
 begin
   with frmMain do
   begin
-    SelectedFiles := ActiveFrame.CloneSelectedOrActiveFiles;
-    try
-      TestArchive(ActiveFrame, SelectedFiles);
-    finally
-      if Assigned(SelectedFiles) then
+    HasConfirmationParam := False;
+
+    for Param in Params do
+    begin
+      if GetParamBoolValue(Param, 'confirmation', BoolValue) then
+      begin
+        HasConfirmationParam := True;
+        bConfirmation := BoolValue;
+      end;
+    end;
+    if not HasConfirmationParam then begin
+      bConfirmation := focTestArchive in gFileOperationsConfirmations;
+    end;
+
+    if (bConfirmation = False) or (ShowDeleteDialog(rsMsgTestArchive, ActiveFrame.FileSource, QueueId)) then
+    begin
+      SelectedFiles := ActiveFrame.CloneSelectedOrActiveFiles;
+      try
+        TestArchive(ActiveFrame, SelectedFiles, QueueId);
+      finally
         FreeAndNil(SelectedFiles);
+      end;
     end;
   end;
 end;