From 71faeb9a0ef828a1c2b40637560438bdb55f2b96 Mon Sep 17 00:00:00 2001 From: Thomas Suckow Date: Mon, 14 Mar 2022 21:07:07 -0700 Subject: [PATCH] Try gzipping the logs --- .github/workflows/freebsd.yml | 2 +- Duplicati/UnitTest/BasicSetupHelper.cs | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index 5f22ace07..4642c0d3e 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -120,4 +120,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: test-logs - path: duplicati_testdata/logs/logfile.log \ No newline at end of file + path: duplicati_testdata/logs/* \ No newline at end of file diff --git a/Duplicati/UnitTest/BasicSetupHelper.cs b/Duplicati/UnitTest/BasicSetupHelper.cs index 01703b486..12503c508 100644 --- a/Duplicati/UnitTest/BasicSetupHelper.cs +++ b/Duplicati/UnitTest/BasicSetupHelper.cs @@ -98,16 +98,14 @@ namespace Duplicati.UnitTest // No-op by default. } + private static int count = 1; + [SetUp] public virtual void SetUp() { systemIO.DirectoryCreate(this.DATAFOLDER); systemIO.DirectoryCreate(this.TARGETFOLDER); - systemIO.DirectoryCreate(this.RESTOREFOLDER); - if (systemIO.FileExists(this.LOGFILE)) - { - systemIO.FileDelete(this.LOGFILE); - } + systemIO.DirectoryCreate(this.RESTOREFOLDER); } [TearDown] @@ -133,6 +131,18 @@ namespace Duplicati.UnitTest { systemIO.FileDelete($"{this.DBFILE}-journal"); } + if (systemIO.FileExists(this.LOGFILE)) + { + var source = new System.IO.FileStream(this.LOGFILE, System.IO.FileMode.Open, System.IO.FileAccess.Read); + var dest = new System.IO.FileStream($"{this.LOGFILE}.{count++}.gz", System.IO.FileMode.Create, System.IO.FileAccess.Write); + var gzip = new System.IO.Compression.GZipStream(dest, System.IO.Compression.CompressionMode.Compress); + source.CopyTo(gzip); + gzip.Flush(); + source.Close(); + gzip.Close(); + dest.Close(); + systemIO.FileDelete(this.LOGFILE); + } } protected virtual Dictionary TestOptions