mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-22 23:15:20 +00:00
Add workaround for in-use files
The `TestBase` is not always able to delete the scratch folder in `Dispose()` because sometimes the files are still in use. This problem appears to be leaked file handles (likely due to incorrect handling of `IDisposable`). To avoid the problem for now, force a garbage collection prior to deleting the scratch folder.
This commit is contained in:
@@ -39,6 +39,12 @@ namespace SharpCompress.Test
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// WARNING: This garbage collection is needed to reclaim leaked file handles
|
||||
// (likely due to improperly handled IDisposables). Without it, The following
|
||||
// delete fails because files are still is use. This GC should be removed once
|
||||
// all the files pass without it.
|
||||
GC.Collect(2, GCCollectionMode.Forced, true, false);
|
||||
|
||||
Directory.Delete(SCRATCH_BASE_PATH, true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user