2

Closed

Setting Entry._Source to "None" after Save Causes Exceptions in Later Operations

description

Saving a zip file twice can cause an exception.
 
[Test]
public void DummyTest()
{
  var zip = Provider.NodeRepository.ZipFile;
  var entries = zip.Entries.Where(e => e.FileName.Contains("Download")).ToArray();
 
  //PART1 - Add directory and save
  zip.AddDirectoryByName("XX");
  zip.Save();

  //PART2 - Rename paths (not related to XX directory from above) and save
  foreach (var zipEntry in entries)
  {
    zipEntry.FileName = zipEntry.FileName.Replace("Download", "Download2");
  }
  zip.Save();
}
 
It seems to reset the Source property of saved entries to "None" which causes exceptions when saving more than once.
 
A description of the issue can be found here:
http://dotnetzip.codeplex.com/Thread/View.aspx?ThreadId=208496
 
As a quick guess, it might be that after saving, the Source should be "ZipFile" rather than "None", but I don't know about the implications though.
Closed Jun 18, 2011 at 2:06 PM by Cheeso
fixed in changeset 79377. First binary with this fix: V1.9.1.6

comments

Cheeso wrote Jun 18, 2011 at 6:31 AM

I've put your code into the test suite; now testing. I don't recall now why I set the _Source to None, rather than ZipFile. I'll have a close look and see ... it could just be a simple mistake ("Typo") in the code.