Clean temp files on startup.
This commit is contained in:
parent
cd2f29e9f5
commit
9ab889f7db
2 changed files with 27 additions and 7 deletions
|
|
@ -19,6 +19,7 @@ namespace RdtClient.Service.Services
|
||||||
Task TestPath(String path);
|
Task TestPath(String path);
|
||||||
Task<Double> TestDownloadSpeed(CancellationToken cancellationToken);
|
Task<Double> TestDownloadSpeed(CancellationToken cancellationToken);
|
||||||
Task<Double> TestWriteSpeed();
|
Task<Double> TestWriteSpeed();
|
||||||
|
void Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Settings : ISettings
|
public class Settings : ISettings
|
||||||
|
|
@ -133,12 +134,7 @@ namespace RdtClient.Service.Services
|
||||||
File.Delete(testFilePath);
|
File.Delete(testFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
var files = Directory.GetFiles(tempPath, "*.dsc", SearchOption.TopDirectoryOnly);
|
Clean();
|
||||||
|
|
||||||
foreach (var file in files)
|
|
||||||
{
|
|
||||||
File.Delete(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
return downloadClient.Speed;
|
return downloadClient.Speed;
|
||||||
}
|
}
|
||||||
|
|
@ -186,5 +182,27 @@ namespace RdtClient.Service.Services
|
||||||
|
|
||||||
return writeSpeed;
|
return writeSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Clean()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var tempPath = GetString("TempPath").Result;
|
||||||
|
|
||||||
|
if (!String.IsNullOrWhiteSpace(tempPath))
|
||||||
|
{
|
||||||
|
var files = Directory.GetFiles(tempPath, "*.dsc", SearchOption.TopDirectoryOnly);
|
||||||
|
|
||||||
|
foreach (var file in files)
|
||||||
|
{
|
||||||
|
File.Delete(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ namespace RdtClient.Web
|
||||||
Service.DiConfig.Config(services);
|
Service.DiConfig.Config(services);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger<Startup> logger)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger<Startup> logger, ISettings settings)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|
@ -133,6 +133,8 @@ namespace RdtClient.Web
|
||||||
spa.Options.DefaultPage = "/index.html";
|
spa.Options.DefaultPage = "/index.html";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
settings.Clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue