1
0
mirror of https://github.com/chylex/Code-Statistics.git synced 2025-07-26 13:59:07 +02:00

Delete downloaded archives from GitHub

This commit is contained in:
chylex 2016-02-29 01:44:47 +01:00
parent 51b4cbdf4b
commit 4e4d8eed1f
2 changed files with 10 additions and 5 deletions
CodeStatistics/Input/Methods

View File

@ -119,7 +119,7 @@ namespace CodeStatistics.Input.Methods{
dlRepoCancel = archive.ExtractAsync(path => {
callbacks.OnReady(new FileSearch(new string[]{ path }));
archive.Dispose();
archive.DeleteAndDispose();
});
};

View File

@ -71,14 +71,19 @@ namespace CodeStatistics.Input.Methods{
Directory.CreateDirectory(Path.Combine(extractPath,dirName));
using(Stream stream = entry.CreateStream()){
using(var fileStream = System.IO.File.Create(Path.Combine(extractPath,entry.Path))){
stream.Seek(0,SeekOrigin.Begin);
stream.CopyTo(fileStream);
using(var sourceStream = entry.CreateStream()){
using(var fileStream = new FileStream(Path.Combine(extractPath,entry.Path),FileMode.OpenOrCreate,FileAccess.Write,FileShare.None)){
sourceStream.Seek(0,SeekOrigin.Begin);
sourceStream.CopyTo(fileStream);
}
}
}
public void DeleteAndDispose(){
Dispose();
System.IO.File.Delete(file);
}
public void Dispose(){
((IDisposable)inner).Dispose();
if (cancelToken != null)cancelToken.Dispose();