mirror of
https://github.com/Jackett/Jackett
synced 2025-02-25 07:32:38 +00:00
Delete JackettUpdate temp files
This commit is contained in:
parent
f96a493c08
commit
bbff25fd54
2 changed files with 34 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue