diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-02-26 15:45:59 -0500 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2016-02-26 15:45:59 -0500 |
| commit | 895a3ea212e9fa8fa0d7c2453bcdbd6176e95d30 (patch) | |
| tree | 3a85dffd1dc0c46e39831b11ba763159099b0f8c /MediaBrowser.Server.Implementations/LiveTv | |
| parent | 0d36fb05a7912d35c77df6c78108df3fa2f3403d (diff) | |
| parent | 26cf0df9cef5cb6ae910b3b2d4150b9c24c8cc96 (diff) | |
Merge pull request #1500 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Server.Implementations/LiveTv')
| -rw-r--r-- | MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index ba3998262..1fbd3cb3e 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -729,6 +729,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV var recordingFileName = _fileSystem.GetValidFilename(RecordingHelper.GetRecordingName(timer, info)).Trim() + ".ts"; recordPath = Path.Combine(recordPath, recordingFileName); + recordPath = EnsureFileUnique(recordPath); _fileSystem.CreateDirectory(Path.GetDirectoryName(recordPath)); var recordingId = info.Id.GetMD5().ToString("N"); @@ -862,6 +863,24 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV } } + private string EnsureFileUnique(string path) + { + var originalPath = path; + var index = 1; + + while (_fileSystem.FileExists(path)) + { + var parent = Path.GetDirectoryName(originalPath); + var name = Path.GetFileNameWithoutExtension(originalPath); + name += "-" + index.ToString(CultureInfo.InvariantCulture); + + path = Path.ChangeExtension(Path.Combine(parent, name), Path.GetExtension(originalPath)); + index++; + } + + return path; + } + private async Task<IRecorder> GetRecorder() { if (GetConfiguration().EnableRecordingEncoding) |
