Merge pull request #4324 from ivandrofly/auto-bk

optimize clean up auto-backup
This commit is contained in:
Nikolaj Olsson 2020-08-25 10:11:09 +02:00 committed by GitHub
commit 1f0a4e7882
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}
}
}