From 4c2d44ac246f308af3097aebd28c6d9a7b640bf3 Mon Sep 17 00:00:00 2001 From: Ivandro IG Jao Date: Mon, 24 Aug 2020 22:37:38 +0100 Subject: [PATCH] optimize clean up auto-backup --- src/Forms/Main.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index 2c5fee4e5..2b62783a8 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -128,6 +128,7 @@ namespace Nikse.SubtitleEdit.Forms private GoogleOrMicrosoftTranslate _googleOrMicrosoftTranslate; private bool _cancelWordSpellCheck = true; + private bool _cleanupHasRun = false; private bool _clearLastFind; private FindType _clearLastFindType = FindType.Normal; @@ -20556,7 +20557,6 @@ namespace Nikse.SubtitleEdit.Forms CallPluginTranslateSelectedLines(sender); } - private void CallPlugin(object sender, bool allowChangeFormat, bool translate) { try @@ -20873,8 +20873,13 @@ namespace Nikse.SubtitleEdit.Forms } } - // let the cleanup proccess be handled by a worker thread - System.Threading.Tasks.Task.Factory.StartNew(() => { RestoreAutoBackup.CleanAutoBackupFolder(Configuration.AutoBackupDirectory, Configuration.Settings.General.AutoBackupDeleteAfterMonths); }); + // the clean up process can only happen minimum once per month. don't keep creating new threading + if (!_cleanupHasRun) + { + // let the cleanup process be handled by worker thread + System.Threading.Tasks.Task.Factory.StartNew(() => { RestoreAutoBackup.CleanAutoBackupFolder(Configuration.AutoBackupDirectory, Configuration.Settings.General.AutoBackupDeleteAfterMonths); }); + _cleanupHasRun = true; + } } }