diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-24 11:08:51 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-24 11:08:51 -0400 |
| commit | b49764dbaafbbf11b6308ec675355696b9e58379 (patch) | |
| tree | 58677308bf98c95f1982a84eb403a01241f0a692 /MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs | |
| parent | 14c464c28a3b9cac207ef741711e31cef1c15378 (diff) | |
fixes #555 - Have clients report seek and queuing capabilities
Diffstat (limited to 'MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs')
| -rw-r--r-- | MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs index 15f955723..bfd626adb 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs @@ -54,33 +54,32 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks /// <returns>Task.</returns> public Task Execute(CancellationToken cancellationToken, IProgress<double> progress) { - return Task.Run(() => - { - // Delete log files more than n days old - var minDateModified = DateTime.UtcNow.AddDays(-(ConfigurationManager.CommonConfiguration.LogFileRetentionDays)); + // Delete log files more than n days old + var minDateModified = DateTime.UtcNow.AddDays(-(ConfigurationManager.CommonConfiguration.LogFileRetentionDays)); + + var filesToDelete = new DirectoryInfo(ConfigurationManager.CommonApplicationPaths.LogDirectoryPath).EnumerateFileSystemInfos("*", SearchOption.AllDirectories) + .Where(f => f.LastWriteTimeUtc < minDateModified) + .ToList(); - var filesToDelete = new DirectoryInfo(ConfigurationManager.CommonApplicationPaths.LogDirectoryPath).EnumerateFileSystemInfos("*", SearchOption.AllDirectories) - .Where(f => f.LastWriteTimeUtc < minDateModified) - .ToList(); + var index = 0; - var index = 0; + foreach (var file in filesToDelete) + { + double percent = index; + percent /= filesToDelete.Count; - foreach (var file in filesToDelete) - { - double percent = index; - percent /= filesToDelete.Count; + progress.Report(100 * percent); - progress.Report(100 * percent); + cancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); + File.Delete(file.FullName); - File.Delete(file.FullName); + index++; + } - index++; - } + progress.Report(100); - progress.Report(100); - }); + return Task.FromResult(true); } /// <summary> |
