Exemplo n.º 1
0
        /// <summary>
        /// Unpacks a set of archives into a given directory.
        /// </summary>
        protected void UnpackArchives(IEnumerable <string> archivesToUnpack, string unpackDirectory)
        {
            foreach (string archiveToUnpack in archivesToUnpack)
            {
                if (request.Target.IsDirectory)
                {
                    // When the target is a nested archive, we need to unpack it to a subdirectory.
                    unpackDirectory = Path.Combine(unpackDirectory, Path.GetFileNameWithoutExtension(archiveToUnpack));
                }

                // Extract archive.
                var unzipStrategy = new UnzipStrategy
                {
                    UnzipNestedArchives = true,
                    WhitelistPattern    = LogsharkConstants.EXTRACTION_FILE_WHITELIST,
                    BlacklistPatterns   = LogsharkConstants.EXTRACTION_FILE_BLACKLISTS
                };

                var         unzipper = new LogsetUnzipper(unzipStrategy, request);
                UnzipResult result   = unzipper.Unzip(archiveToUnpack, unpackDirectory, deleteOnFinish: request.Target.IsDirectory);

                // Update target size to include the size of the zip contents (but not the zip itself if it's a nested zip in a directory).
                request.Target.UncompressedSize += result.FullUncompressedSize;
                if (request.Target.IsDirectory)
                {
                    request.Target.UncompressedSize -= result.CompressedSize;
                }
            }
        }
Exemplo n.º 2
0
 public Unzipper(UnzipStrategy strategy)
 {
     Strategy = strategy;
 }
Exemplo n.º 3
0
 public LogsetUnzipper(UnzipStrategy unzipStrategy, LogsharkRequest request)
     : base(unzipStrategy)
 {
     this.request = request;
 }