Actually fixed PK3 synchronization

This commit is contained in:
ZZYZX 2019-12-31 13:46:30 +02:00
parent fa053bc097
commit 961b5fdb33

View file

@ -40,7 +40,6 @@ namespace CodeImp.DoomBuilder.Data
private /*readonly*/ ArchiveType archivetype; //mxd private /*readonly*/ ArchiveType archivetype; //mxd
private /*readonly*/ Dictionary<string, byte[]> sevenzipentries; //mxd private /*readonly*/ Dictionary<string, byte[]> sevenzipentries; //mxd
private bool batchmode = true; //mxd private bool batchmode = true; //mxd
private bool issevenzip = false;
#endregion #endregion
@ -103,8 +102,6 @@ namespace CodeImp.DoomBuilder.Data
sevenzipentries.Add(reader.Entry.Key.ToLowerInvariant(), s.ToArray()); sevenzipentries.Add(reader.Entry.Key.ToLowerInvariant(), s.ToArray());
fileentries.Add(new DirectoryFileEntry(reader.Entry.Key)); fileentries.Add(new DirectoryFileEntry(reader.Entry.Key));
} }
issevenzip = true;
} }
else else
{ {
@ -159,15 +156,15 @@ namespace CodeImp.DoomBuilder.Data
//mxd //mxd
private void UpdateArchive(bool enable) private void UpdateArchive(bool enable)
{ {
if(archivetype == ArchiveType.SevenZip) return; lock (this)
{
if (archivetype == ArchiveType.SevenZip) return;
if(enable && archive == null) if (enable && archive == null)
{ {
archive = ArchiveFactory.Open(location.location); archive = ArchiveFactory.Open(location.location);
} }
else if(!enable && !batchmode && archive != null) else if (!enable && !batchmode && archive != null)
{
lock (archive)
{ {
archive.Dispose(); archive.Dispose();
archive = null; archive = null;
@ -513,26 +510,21 @@ namespace CodeImp.DoomBuilder.Data
} }
else else
{ {
lock(this) lock (this)
{ {
UpdateArchive(true); UpdateArchive(true);
lock (archive) foreach (var entry in archive.Entries)
{ {
if (entry.IsDirectory) continue;
foreach (var entry in archive.Entries) // Is this the entry we are looking for?
if (string.Compare(entry.Key, fn, true) == 0)
{ {
if (entry.IsDirectory) continue; filedata = new MemoryStream();
entry.WriteTo(filedata);
// Is this the entry we are looking for? break;
if (string.Compare(entry.Key, fn, true) == 0)
{
filedata = new MemoryStream();
entry.WriteTo(filedata);
break;
}
} }
} }
UpdateArchive(false); UpdateArchive(false);