Fix ReadWriteZipFile crashing on update.
This commit is contained in:
@@ -97,13 +97,14 @@ namespace OpenRA.FileSystem
|
|||||||
|
|
||||||
sealed class ReadWriteZipFile : ReadOnlyZipFile, IReadWritePackage
|
sealed class ReadWriteZipFile : ReadOnlyZipFile, IReadWritePackage
|
||||||
{
|
{
|
||||||
readonly MemoryStream pkgStream;
|
readonly MemoryStream pkgStream = new MemoryStream();
|
||||||
|
|
||||||
public ReadWriteZipFile(string filename, bool create = false)
|
public ReadWriteZipFile(string filename, bool create = false)
|
||||||
{
|
{
|
||||||
// SharpZipLib breaks when asked to update archives loaded from outside streams or files
|
// SharpZipLib breaks when asked to update archives loaded from outside streams or files
|
||||||
// We can work around this by creating a clean in-memory-only file, cutting all outside references
|
// We can work around this by creating a clean in-memory-only file, cutting all outside references
|
||||||
pkgStream = create ? new MemoryStream() : new MemoryStream(File.ReadAllBytes(filename));
|
if (!create)
|
||||||
|
new MemoryStream(File.ReadAllBytes(filename)).CopyTo(pkgStream);
|
||||||
|
|
||||||
pkgStream.Position = 0;
|
pkgStream.Position = 0;
|
||||||
pkg = ZipFileHelper.Create(pkgStream);
|
pkg = ZipFileHelper.Create(pkgStream);
|
||||||
|
|||||||
Reference in New Issue
Block a user