Forum Discussion

Oferv's avatar
Oferv
Super Contributor
13 years ago

sIpacker is unable to pack the files

Hi,



Last action i'm doing after the script has finish running is to pack the results in order to email them.

but,i'm facing a problem where sometimes the SIpacker is managing packing the files and sometimes it doesn't and display the error "unable to pack the files" in the results file.



see attached



why is that?why it's not consistent?



Thanks
  • Julia_K's avatar
    Julia_K
    SmartBear Alumni (Retired)

    Hello Ofer,


    Could you please specify what information is displayed in the Additional Information panel for your "Unable to pack the files" errors?


    Thank you.

  • Oferv's avatar
    Oferv
    Super Contributor
    Yes,it says "The archiver has returned an error."
  • Oferv's avatar
    Oferv
    Super Contributor
    Hi Julla,



    I've noticed that when i delete manually the compressed file and run the script again the log compressed properly.why it can't "step" on the old file or create the latest next to it?



    Thanks
  • Julia_K's avatar
    Julia_K
    SmartBear Alumni (Retired)
    Ofer,

    Could you please post here the script you are using to pack test results? Are you using the Pack method of the slPacker object? How do you specify the path to the resulting archive file?

    Thank you.
  • Oferv's avatar
    Oferv
    Super Contributor
    There you go,




    function PackResults()

    {

      var WorkDir, FileName, FileList, ArchivePath;

      WorkDir = Project["ConfigPath"] + "SentReports\\";

      FileName = WorkDir + "Results.mht";  

      Log["SaveResultsAs"](FileName, 2);

      FileList = slPacker["GetFileListFromFolder"](WorkDir);

      ArchivePath = WorkDir + "CompressedResults";

      if (slPacker["Pack"](FileList, WorkDir, ArchivePath))

        Log["Message"]("Files compressed successfully.");

      else

        Log["Message"]("Files wasn't compressed successfully.");


    it is a copy from your website.



    Thanks
  • Julia_K's avatar
    Julia_K
    SmartBear Alumni (Retired)

    Hello Ofer,

    Thank you for your code.

    I have reproduced the issue you described. The example in our Help system is incorrect indeed. The PackResults routine fails during the subsequent runs, because the target archive tries to pack itself. Thank you for drawing our attention to this issue. We will fix the example. Sorry for the inconvenience.

    Meanwhile, you can fix your code in one of the following ways:

    1. Add a command that will delete previous runs’ packed results to your code:



    function PackResults()

    {

      var WorkDir = Project["ConfigPath"] + "SentReports\\";

      // Clears the previous run results

      aqFileSystem["DeleteFolder"](WorkDir, true);

      var FileName = WorkDir + "Results.mht";  

      Log["SaveResultsAs"](FileName, 2);

      var FileList = slPacker["GetFileListFromFolder"](WorkDir);

      var ArchivePath = WorkDir + "CompressedResults";

      if (slPacker["Pack"](FileList, WorkDir, ArchivePath))

        Log["Message"]("Files were compressed successfully.");

      else

        Log["Message"]("Files weren't compressed successfully.");

    }




    2. Place the log files to pack and the resulting archive to separate folders.



    function PackResults()

    {

      // Specifies the folder where the files to pack reside

      var WorkDir = Project["ConfigPath"] + "WorkDir\\";

      // Specifies the folder where the resulting archive will be placed

      var SentReports = Project["ConfigPath"] + "SentReports\\";

      aqFileSystem["CreateFolder"](SentReports); 

     

      var FileName = WorkDir + "Results.mht";  

     

      Log["SaveResultsAs"](FileName, 2);

     

      var FileList = slPacker["GetFileListFromFolder"](WorkDir);

      var ArchivePath = SentReports + "CompressedResults";

     

      if (slPacker["Pack"](FileList, WorkDir, ArchivePath))

        Log["Message"]("Files were compressed successfully.");

      else

        Log["Message"]("Files weren't compressed successfully.");

    }



    Please let us know if this does not help or if you have any additional questions.

    Thank you.