TarArchive seems to hold onto resources #7

Closed
opened 2026-01-29 22:03:24 +00:00 by claunia · 1 comment
Owner

Originally created by @TheAngryByrd on GitHub (Dec 12, 2013).

Originally assigned to: @adamhathcock on GitHub.

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!

Originally created by @TheAngryByrd on GitHub (Dec 12, 2013). Originally assigned to: @adamhathcock on GitHub. 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!
Author
Owner

@adamhathcock commented on GitHub (Dec 15, 2013):

Thanks. I just fixed this I believe:
fe8c6aec5f

@adamhathcock commented on GitHub (Dec 15, 2013): Thanks. I just fixed this I believe: https://github.com/adamhathcock/sharpcompress/commit/fe8c6aec5f594fe10967171dc24c76509c1ff71c
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#7