mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Delete JackettUpdate temp files
This commit is contained in:
@@ -177,6 +177,7 @@ namespace Jackett.Services
|
||||
}
|
||||
indexerService.SortIndexers();
|
||||
client.Init();
|
||||
updater.CleanupTempDir();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
|
@@ -24,6 +24,7 @@ namespace Jackett.Services
|
||||
{
|
||||
void StartUpdateChecker();
|
||||
void CheckForUpdatesNow();
|
||||
void CleanupTempDir();
|
||||
}
|
||||
|
||||
public class UpdateService: IUpdateService
|
||||
@@ -172,6 +173,38 @@ namespace Jackett.Services
|
||||
return req;
|
||||
}
|
||||
|
||||
public void CleanupTempDir()
|
||||
{
|
||||
var tempDir = Path.GetTempPath();
|
||||
|
||||
if (!Directory.Exists(tempDir))
|
||||
{
|
||||
logger.Error("Temp dir doesn't exist: " + tempDir.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DirectoryInfo d = new DirectoryInfo(tempDir);
|
||||
foreach (var dir in d.GetDirectories("JackettUpdate-*"))
|
||||
{
|
||||
try {
|
||||
logger.Info("Deleting JackettUpdate temp files from " + dir.FullName);
|
||||
dir.Delete(true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error("Error while deleting temp files from " + dir.FullName);
|
||||
logger.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error("Unexpected error while deleting temp files from " + tempDir.ToString());
|
||||
logger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<string> DownloadRelease(List<Asset> assets, bool isWindows, string version)
|
||||
{
|
||||
var targetAsset = assets.Where(a => isWindows ? a.Browser_download_url.ToLowerInvariant().EndsWith(".zip") : a.Browser_download_url.ToLowerInvariant().EndsWith(".gz")).FirstOrDefault();
|
||||
|
Reference in New Issue
Block a user