mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-21 17:11:29 +01:00
Removed code for bz2 because it has never been used/exposed in the UI.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
ebcef64a24
commit
8804038dc4
@ -41,11 +41,10 @@ namespace XenAdminTests.ArchiveTests
|
||||
{
|
||||
[TestCase(ArchiveFactory.Type.Tar, ExpectedResult = typeof(SharpZipTarArchiveIterator))]
|
||||
[TestCase(ArchiveFactory.Type.TarGz, ExpectedResult = typeof(SharpZipTarArchiveIterator))]
|
||||
[TestCase(ArchiveFactory.Type.TarBz2, ExpectedResult = typeof(SharpZipTarArchiveIterator))]
|
||||
[Test]
|
||||
public Type TestReaderGeneration(int archiveType)
|
||||
{
|
||||
string target = TestUtils.GetTestResource("emptyfile.bz2");
|
||||
string target = TestUtils.GetTestResource("emptyfile.gz");
|
||||
|
||||
using (var ms = new MemoryStream(File.ReadAllBytes(target)))
|
||||
using (var iterator = ArchiveFactory.Reader((ArchiveFactory.Type)archiveType, ms))
|
||||
@ -66,7 +65,6 @@ namespace XenAdminTests.ArchiveTests
|
||||
}
|
||||
|
||||
[TestCase(ArchiveFactory.Type.TarGz)]
|
||||
[TestCase(ArchiveFactory.Type.TarBz2)]
|
||||
[Test]
|
||||
public void TestWriterGenerationUnsupported(int archiveType)
|
||||
{
|
||||
|
@ -40,7 +40,6 @@ namespace XenAdminTests.CompressionTests
|
||||
public class CompressionFactoryTests
|
||||
{
|
||||
[TestCase(CompressionFactory.Type.Gz, ExpectedResult = typeof(DotNetZipGZipOutputStream))]
|
||||
[TestCase(CompressionFactory.Type.Bz2, ExpectedResult = typeof(DotNetZipBZip2OutputStream))]
|
||||
[Test]
|
||||
public Type TestWriterGeneration(int archiveType)
|
||||
{
|
||||
@ -52,37 +51,16 @@ namespace XenAdminTests.CompressionTests
|
||||
}
|
||||
|
||||
[TestCase(CompressionFactory.Type.Gz, ExpectedResult = typeof(DotNetZipGZipInputStream))]
|
||||
[TestCase(CompressionFactory.Type.Bz2, ExpectedResult = typeof(DotNetZipBZip2InputStream))]
|
||||
[Test]
|
||||
public Type TestReaderGenerationWithFile(int archiveType)
|
||||
{
|
||||
string target = TestUtils.GetTestResource("emptyfile.bz2");
|
||||
/*
|
||||
* Note: Reading a bzip2 file in as a byte[] works for gzip as well as bzip2 stream
|
||||
* as the implementation of bzip2 must be initialised with a string containing a
|
||||
* header, EOF etc. whereas gzip doesn't mind so the following will work despite
|
||||
* opening a gzip compression stream with a bzip2 data
|
||||
*/
|
||||
string target = TestUtils.GetTestResource("emptyfile.gz");
|
||||
|
||||
using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(target)))
|
||||
{
|
||||
using (var providedStream = CompressionFactory.Reader((CompressionFactory.Type)archiveType, ms))
|
||||
return providedStream.GetType();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[TestCase(CompressionFactory.Type.Bz2)]
|
||||
[Description("Checks that a BZip2 stream without actual BZip2 data, header, data etc., will throw an exception")]
|
||||
[Test]
|
||||
public void TestReaderGenerationWithoutFile(int archiveType)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
Assert.Throws(typeof(IOException), () =>
|
||||
{
|
||||
using (CompressionFactory.Reader((CompressionFactory.Type)archiveType, ms))
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ namespace XenAdminTests.CompressionTests
|
||||
{
|
||||
[Category(TestCategories.Unit)]
|
||||
[TestFixture(typeof(DotNetZipGZipInputStream), typeof(DotNetZipGZipOutputStream))]
|
||||
[TestFixture(typeof(DotNetZipBZip2InputStream), typeof(DotNetZipBZip2OutputStream))]
|
||||
public class ThirdPartyCompressionTests<TI, TO>
|
||||
where TI : CompressionStream, new()
|
||||
where TO : CompressionStream, new()
|
||||
|
Binary file not shown.
BIN
XenAdminTests/TestResources/emptyfile.gz
Normal file
BIN
XenAdminTests/TestResources/emptyfile.gz
Normal file
Binary file not shown.
@ -133,9 +133,6 @@
|
||||
<Compile Include="XenOvf\FileDigestTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="TestResources\emptyfile.bz2">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="TestResources\PluginResources\PowerShellTest.ps1">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
@ -47,7 +47,6 @@ namespace XenCenterLib.Archive
|
||||
{
|
||||
Tar,
|
||||
TarGz,
|
||||
TarBz2,
|
||||
Zip
|
||||
}
|
||||
|
||||
@ -65,8 +64,6 @@ namespace XenCenterLib.Archive
|
||||
return new SharpZipTarArchiveIterator(packagedData);
|
||||
if (archiveType == Type.TarGz)
|
||||
return new SharpZipTarArchiveIterator(packagedData, CompressionFactory.Type.Gz);
|
||||
if (archiveType == Type.TarBz2)
|
||||
return new SharpZipTarArchiveIterator(packagedData, CompressionFactory.Type.Bz2);
|
||||
if (archiveType == Type.Zip)
|
||||
return new DotNetZipZipIterator(packagedData);
|
||||
|
||||
|
@ -52,8 +52,6 @@ namespace XenCenterLib.Archive
|
||||
{
|
||||
if (compressionType == CompressionFactory.Type.Gz)
|
||||
compressionStream = CompressionFactory.Reader(CompressionFactory.Type.Gz, compressedTarFile);
|
||||
else if (compressionType == CompressionFactory.Type.Bz2)
|
||||
compressionStream = CompressionFactory.Reader(CompressionFactory.Type.Bz2, compressedTarFile);
|
||||
else
|
||||
throw new NotSupportedException($"Type {compressionType} is not supported by ArchiveIterator");
|
||||
|
||||
|
@ -1,80 +0,0 @@
|
||||
/* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using Ionic.BZip2;
|
||||
|
||||
namespace XenCenterLib.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// A class that can compress a bzip2 data stream type
|
||||
/// </summary>
|
||||
class DotNetZipBZip2OutputStream : CompressionStream
|
||||
{
|
||||
public DotNetZipBZip2OutputStream()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DotNetZipBZip2OutputStream(Stream inputStream)
|
||||
{
|
||||
zipStream = new BZip2OutputStream(inputStream);
|
||||
}
|
||||
|
||||
public override void SetBaseStream(Stream baseStream)
|
||||
{
|
||||
zipStream = new BZip2OutputStream(baseStream);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A class that can decompress a bzip2 data stream type
|
||||
/// </summary>
|
||||
class DotNetZipBZip2InputStream : CompressionStream
|
||||
{
|
||||
public DotNetZipBZip2InputStream()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DotNetZipBZip2InputStream(Stream outputStream)
|
||||
{
|
||||
zipStream = new BZip2InputStream(outputStream);
|
||||
}
|
||||
|
||||
public override void SetBaseStream(Stream outputStream)
|
||||
{
|
||||
zipStream = new BZip2InputStream(outputStream);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -44,8 +44,7 @@ namespace XenCenterLib.Compression
|
||||
/// </summary>
|
||||
public enum Type
|
||||
{
|
||||
Gz,
|
||||
Bz2
|
||||
Gz
|
||||
}
|
||||
|
||||
public static string StringOf(this Type t)
|
||||
@ -54,8 +53,6 @@ namespace XenCenterLib.Compression
|
||||
{
|
||||
case Type.Gz:
|
||||
return "Gzip";
|
||||
case Type.Bz2:
|
||||
return "BZip2";
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(t), t, null);
|
||||
}
|
||||
@ -67,8 +64,6 @@ namespace XenCenterLib.Compression
|
||||
{
|
||||
case Type.Gz:
|
||||
return ".gz";
|
||||
case Type.Bz2:
|
||||
return ".bz2";
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(t), t, null);
|
||||
}
|
||||
@ -86,9 +81,6 @@ namespace XenCenterLib.Compression
|
||||
if (compressionType == Type.Gz)
|
||||
return new DotNetZipGZipInputStream(compressedDataSource);
|
||||
|
||||
if (compressionType == Type.Bz2)
|
||||
return new DotNetZipBZip2InputStream(compressedDataSource);
|
||||
|
||||
throw new NotSupportedException(String.Format("Type: {0} is not supported by CompressionStream Reader", compressionType));
|
||||
}
|
||||
|
||||
@ -104,9 +96,6 @@ namespace XenCenterLib.Compression
|
||||
if (compressionType == Type.Gz)
|
||||
return new DotNetZipGZipOutputStream(compressedDataTarget);
|
||||
|
||||
if (compressionType == Type.Bz2)
|
||||
return new DotNetZipBZip2OutputStream(compressedDataTarget);
|
||||
|
||||
throw new NotSupportedException(String.Format("Type: {0} is not supported by CompressionStream Writer", compressionType));
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ using System.IO;
|
||||
namespace XenCenterLib.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// A class that can compress a bzip2 data stream type
|
||||
/// A class that can compress a gzip data stream type
|
||||
/// </summary>
|
||||
class DotNetZipGZipOutputStream : CompressionStream
|
||||
{
|
||||
@ -56,7 +56,7 @@ namespace XenCenterLib.Compression
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A class that can decompress a bzip2 data stream type
|
||||
/// A class that can decompress a gzip data stream type
|
||||
/// </summary>
|
||||
class DotNetZipGZipInputStream : CompressionStream
|
||||
{
|
||||
|
@ -62,7 +62,6 @@
|
||||
<Compile Include="Archive\TarSanitization.cs" />
|
||||
<Compile Include="Archive\ZipArchiveIterator.cs" />
|
||||
<Compile Include="Archive\ZipArchiveWriter.cs" />
|
||||
<Compile Include="Compression\BZip2Streams.cs" />
|
||||
<Compile Include="Compression\CompressionFactory.cs" />
|
||||
<Compile Include="Compression\CompressionStream.cs" />
|
||||
<Compile Include="Compression\GZipStreams.cs" />
|
||||
|
@ -298,7 +298,7 @@ namespace XenAdmin.Actions.OvfActions
|
||||
|
||||
// the compressed file will be replaced by the uncompressed, hence we need
|
||||
// to use it with its disk extension (vmdk, vhd, etc.)
|
||||
if (ext.ToLower().EndsWith(".gz") || ext.ToLower().EndsWith(".bz2"))
|
||||
if (ext.ToLower().EndsWith(".gz"))
|
||||
{
|
||||
sourcefile = Path.Combine(pathToOvf, "unc_" + Path.GetFileNameWithoutExtension(filename));
|
||||
ext = Path.GetExtension(sourcefile);
|
||||
|
@ -71,11 +71,9 @@ namespace XenOvf
|
||||
|
||||
if (file.compression.ToLower() == "gzip")
|
||||
method = CompressionFactory.Type.Gz;
|
||||
else if (file.compression.ToLower() == "bzip2")
|
||||
method = CompressionFactory.Type.Bz2;
|
||||
else
|
||||
{
|
||||
log.ErrorFormat("File {0} uses unsupported method {1}. Must be Gzip or BZip2. Skipping.",
|
||||
log.ErrorFormat("File {0} uses unsupported method {1}. Must be Gzip. Skipping.",
|
||||
file.href, file.compression);
|
||||
continue;
|
||||
}
|
||||
|
@ -3431,7 +3431,7 @@ namespace XenOvf
|
||||
/// <summary>
|
||||
/// Find the filename for the given RASD.
|
||||
/// The RASD must Resource Type: 17, 19, 21 and be a hard disk image.
|
||||
/// The file may be compressed (gzip/bzip2)
|
||||
/// The file may be compressed (gzip)
|
||||
/// </summary>
|
||||
public static string FindRasdFileName(EnvelopeType ovfEnv, RASD_Type rasd, out CompressionFactory.Type? compression)
|
||||
{
|
||||
@ -3482,12 +3482,6 @@ namespace XenOvf
|
||||
return filer.href;
|
||||
}
|
||||
|
||||
if (filer.compression.ToLower().Equals("bzip2"))
|
||||
{
|
||||
compression = CompressionFactory.Type.Bz2;
|
||||
return filer.href;
|
||||
}
|
||||
|
||||
throw new NotSupportedException(string.Format(Messages.COMPRESS_INVALID_METHOD, filer.compression));
|
||||
}
|
||||
}
|
||||
|
@ -229,8 +229,6 @@ namespace XenOvf
|
||||
|
||||
if (string.Compare(extension, ".gz", true) == 0)
|
||||
_tarType = ArchiveFactory.Type.TarGz;
|
||||
else if (string.Compare(extension, ".bz2", true) == 0)
|
||||
_tarType = ArchiveFactory.Type.TarBz2;
|
||||
}
|
||||
|
||||
public override string DescriptorFileName
|
||||
|
@ -129,7 +129,7 @@
|
||||
</xs:attribute>
|
||||
<xs:attribute name="compression" type="xs:string" default="" use="optional">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Compression type (gzip, bzip2, or none if empty or not
|
||||
<xs:documentation>Compression type (gzip, or none if empty or not
|
||||
specified)</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
|
Loading…
Reference in New Issue
Block a user