Example #1
0
        protected override void Run(bool success)
        {
            base.Run(success);

            Logger.Trace("Unzip File: {0} to Path: {1}", archiveFilePath, extractedPath);

            try
            {
                zipHelper.Extract(archiveFilePath, extractedPath, Token, zipFileProgress, estimatedDurationProgress);
            }
            catch (Exception ex)
            {
                var message = "Error Unzipping file";

                Logger.Error(ex, message);
                throw new UnzipTaskException(message);
            }

            if (expectedMD5 != null)
            {
                var calculatedMD5 = fileSystem.CalculateFolderMD5(extractedPath);
                if (!calculatedMD5.Equals(expectedMD5, StringComparison.InvariantCultureIgnoreCase))
                {
                    extractedPath.DeleteIfExists();

                    var message = $"Extracted MD5: {calculatedMD5} Does not match expected: {expectedMD5}";
                    Logger.Error(message);

                    throw new UnzipTaskException(message);
                }
            }

            Logger.Trace("Completed Unzip");
        }