File Updating Woes

Mar 23, 2010 at 10:28 PM

I am looking to update a small number of files in a zip (125 out of some 10000, specifically).  I've been messing around with this library, checking discussions on here, and reading the documentation and cannot for the life of me get this to work how id like.  Heres the closest that I've come:

 

 

foreach (string file in Directory.GetFiles(path, "*.inibin", SearchOption.AllDirectories))
{
    string relativePath = file.Substring(subPath.Length);
    relativePath = relativePath.Substring(0, relativePath.LastIndexOf(@"\"));
    zip.UpdateFile(file, relativePath);
}

 

My directory structure (and zip file structure) are as follows :

DATA\Characters\<NAME>\<NAME>.inibin

or as an example:

DATA\Characters\Ammon\Ammon.inibin

My goal is to update all of the *.inibin files in the Data\Characters subdirectories.  In the above code, i set the relativePath variable to be "DATA\Characters\<NAME>".  When i save the Zip, i end up with TWO <NAME>.inibin files in each folder.  I don't even understand how that makes sense.  They are placed in the right folder with the above code, but the existing file in the archive is not updated, it seems to be duplicated.  When I extracted this file, I was prompted with a file replace as well (I guess the newer file replaces the older on extraction?).

I've been making similar attempts (see:failures) with the UpdateEntry method, as this is the method that I think I will ideally want to use.  Most alarmingly, when trying to use RemoveEntry with "DATA\Characters\<NAME>\<NAME>.inibin" (which is the appropriate filename that I can see when debugging), I get an exception. 

 

Am I missing something?  Is there something that I've been doing blatantly wrong?  I hope I didn't make too detailed of a post!

Coordinator
Mar 23, 2010 at 10:53 PM

NO, your post is not "too detailed".  HA!

What version of the library are you using? 

I changed the way zip entries are handled internally, and that caused some problems with the handling of duplicate names.  I've fixed that problem but I haven't released a build yet, with that fix.

I'd like to see the exception you get with RemoveEntry().

I'll write some tests to see if I can duplicate what you're seeing.  I'll get back to you.

Mar 23, 2010 at 11:47 PM

Wow, thanks for the incredibly fast response!  I am using the latest version of the library - I just downloaded it today to see what I could cook up with it.

 

The error that I get when I attempt to use RemoveEntry with the relativePath variable is just "The entry you specified was not found in the zip archive."  There was no inner exception or any other seemingly useful data. Let me know if theres anything else I can provide you with!

 

As a workaround, I was able to get this kludge to work:

...
zip.RemoveEntry(getZipEntry(zip, relativePath))
...

private ZipEntry getZipEntry(ZipFile theZip, string fileName)
{
	foreach (ZipEntry e in theZip.SelectEntries("*.inibin"))
	{
		if (e.FileName.Equals(fileName))
		{
			return e;
		}
	}
	return null;
}
However - after successfully removing the entry, I was still getting 2 files in the zip file.  Maybe an Entry doesnt behave as I am expecting?

Coordinator
Mar 24, 2010 at 10:50 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Mar 25, 2010 at 3:30 PM

So you were able to reproduce this then?  Were you seeing the same issue that I was regarding the duplicate entries?

Are you aiming to fix this for the next release, and when should we expect that?  Thanks!

Coordinator
Mar 26, 2010 at 5:26 PM

No, I haven't tried yet.  I should be able to spend some time on it later today.

 

May 11, 2010 at 10:49 PM

There is DEFINITELY a bug here.  I was getting into testing this some more, and I was having similar issues.  Duplicate entries being created in the zip, failure to remove entries that I KNOW to exist, etc.  For instance, this (silly, but damning) example fails:

 

ICollection<ZipEntry> entries = zip.SelectEntries("*.inibin");

foreach(ZipEntry entry in entries)
{
   zip.RemoveEntry(entry)
}

To verify that it was a bug, I downloaded version 1.8.  I ran my code with it, and... voila.  Has anyone else made a comment on this bug?  Have you been able to reproduce it Cheeso?

May 17, 2010 at 10:26 PM
Hello all, I am having the same issue with my program. So your saying version 1.8 works correctly? It’s strange how we are both actually working on the same project. I recognized that code immediately as LoL.
May 17, 2010 at 11:50 PM
1TBSSD wrote:
Hello all, I am having the same issue with my program. So your saying version 1.8 works correctly? It’s strange how we are both actually working on the same project. I recognized that code immediately as LoL.

Haha, thats great.  Are you one of the developers of one of the already posted 2 projects?  I've been working on mine for quite awhile now but havent posted mine yet. 

Anyways - yes version 1.8 is working properly for me.  Good luck!

May 18, 2010 at 3:31 AM
yourbuddypal wrote:
1TBSSD wrote:
Hello all, I am having the same issue with my program. So your saying version 1.8 works correctly? It’s strange how we are both actually working on the same project. I recognized that code immediately as LoL.

Haha, thats great.  Are you one of the developers of one of the already posted 2 projects?  I've been working on mine for quite awhile now but havent posted mine yet. 

Anyways - yes version 1.8 is working properly for me.  Good luck!

 I am not one of the two on the forums. I have my own seperate site for my project. http://sites.google.com/site/lolchanger. Thanks for the info on 1.8. It works great.