diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-08-14 09:24:30 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-08-14 09:24:30 -0400 |
| commit | 9c5cceb4ecc277ffb5a3a988f655ad674bf41c58 (patch) | |
| tree | 0077c03cb06e2dc7700315f90db9ee51fedeb00d /MediaBrowser.Server.Implementations/Channels | |
| parent | 02e25b48550ffef016d20fe3f070c8552633cbef (diff) | |
update translations
Diffstat (limited to 'MediaBrowser.Server.Implementations/Channels')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Channels/ChannelDownloadScheduledTask.cs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelDownloadScheduledTask.cs b/MediaBrowser.Server.Implementations/Channels/ChannelDownloadScheduledTask.cs index 567092cae..65e5a0549 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelDownloadScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelDownloadScheduledTask.cs @@ -7,6 +7,7 @@ using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Channels; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Logging; using MediaBrowser.Model.MediaInfo; @@ -154,7 +155,7 @@ namespace MediaBrowser.Server.Implementations.Channels { try { - await DownloadChannelItem(item, cancellationToken, path); + await DownloadChannelItem(item, options, cancellationToken, path); } catch (OperationCanceledException) { @@ -176,9 +177,18 @@ namespace MediaBrowser.Server.Implementations.Channels } private async Task DownloadChannelItem(BaseItemDto item, + ChannelOptions channelOptions, CancellationToken cancellationToken, string path) { + if (channelOptions.DownloadSizeLimit.HasValue) + { + if (IsSizeLimitReached(path, channelOptions.DownloadSizeLimit.Value)) + { + return; + } + } + var sources = await _manager.GetChannelItemMediaSources(item.Id, cancellationToken) .ConfigureAwait(false); @@ -253,6 +263,25 @@ namespace MediaBrowser.Server.Implementations.Channels } } + private bool IsSizeLimitReached(string path, double gbLimit) + { + var byteLimit = gbLimit*1000000000; + + long total = 0; + + foreach (var file in new DirectoryInfo(path).EnumerateFiles("*", SearchOption.AllDirectories)) + { + total += file.Length; + + if (total >= byteLimit) + { + return true; + } + } + + return false; + } + private async Task RefreshMediaSourceItems(IEnumerable<MediaSourceInfo> items, CancellationToken cancellationToken) { foreach (var item in items) |
