adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.25k stars 479 forks source link

TarArchive seems to hold onto resources #10

Closed TheAngryByrd closed 10 years ago

TheAngryByrd commented 10 years ago

Creating a new TarArchive seems to hold on to resources after disposing of it.

            var temp = Path.Combine(ThisLocation, Path.GetRandomFileName());
            CopyFiles(TheItems, temp);

            var newTarball = Path.Combine(ThisLocation, "MyTarBall.tgz");
            using (var archive = TarArchive.Create())
            {
                archive.AddAllFromDirectory(temp);
                archive.SaveTo(newTarball, CompressionType.GZip);
            }

            //An exception of type 'System.IO.IOException' occurred in mscorlib.dll but was not handled in user code
            //Additional information: The process cannot access the file 'New Text Document.txt' because it is being 
            //used by another process.
            Directory.Delete(temp, true);

The sample to repro is here: https://github.com/TheAngryByrd/SharpCompressHoldingOntoFiles/

Thanks!

adamhathcock commented 10 years ago

Thanks. I just fixed this I believe: https://github.com/adamhathcock/sharpcompress/commit/fe8c6aec5f594fe10967171dc24c76509c1ff71c