From 08931dabff86212390fc3f25d04baad0e15b03e1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 16 Jul 2016 14:02:39 -0400 Subject: update listviews --- .../Playlists/PlaylistManager.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs b/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs index 53c03b91c..ba1559bd0 100644 --- a/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs +++ b/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs @@ -247,15 +247,18 @@ namespace MediaBrowser.Server.Implementations.Playlists return; } - if (newIndex > oldIndex) - { - newIndex--; - } - var item = playlist.LinkedChildren[oldIndex]; playlist.LinkedChildren.Remove(item); - playlist.LinkedChildren.Insert(newIndex, item); + + if (newIndex >= playlist.LinkedChildren.Count) + { + playlist.LinkedChildren.Add(item); + } + else + { + playlist.LinkedChildren.Insert(newIndex, item); + } await playlist.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); } -- cgit v1.2.3 From b6979fa28a7fac0b40161d789dc3bbc2bcccb7a9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 17 Jul 2016 12:59:40 -0400 Subject: pass along date modified --- Emby.Drawing/ImageProcessor.cs | 53 ++++++++++++---------- MediaBrowser.Api/Images/ImageService.cs | 1 + MediaBrowser.Controller/Drawing/IImageProcessor.cs | 2 +- .../HttpServer/HttpResultFactory.cs | 6 ++- 4 files changed, 36 insertions(+), 26 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index dc93cb730..3288229a2 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -163,7 +163,7 @@ namespace Emby.Drawing return _imageEncoder.SupportedOutputFormats; } - public async Task> ProcessImage(ImageProcessingOptions options) + public async Task> ProcessImage(ImageProcessingOptions options) { if (options == null) { @@ -178,14 +178,13 @@ namespace Emby.Drawing } var originalImagePath = originalImage.Path; + var dateModified = originalImage.DateModified; if (!_imageEncoder.SupportsImageEncoding) { - return new Tuple(originalImagePath, MimeTypes.GetMimeType(originalImagePath)); + return new Tuple(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified); } - var dateModified = originalImage.DateModified; - if (options.CropWhiteSpace && _imageEncoder.SupportsImageEncoding) { var tuple = await GetWhitespaceCroppedImage(originalImagePath, dateModified).ConfigureAwait(false); @@ -211,7 +210,7 @@ namespace Emby.Drawing if (options.HasDefaultOptions(originalImagePath)) { // Just spit out the original file if all the options are default - return new Tuple(originalImagePath, MimeTypes.GetMimeType(originalImagePath)); + return new Tuple(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified); } ImageSize? originalImageSize; @@ -221,7 +220,7 @@ namespace Emby.Drawing if (options.HasDefaultOptions(originalImagePath, originalImageSize.Value)) { // Just spit out the original file if all the options are default - return new Tuple(originalImagePath, MimeTypes.GetMimeType(originalImagePath)); + return new Tuple(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified); } } catch @@ -235,10 +234,6 @@ namespace Emby.Drawing var outputFormat = GetOutputFormat(options.SupportedOutputFormats[0]); var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, outputFormat, options.AddPlayedIndicator, options.PercentPlayed, options.UnplayedCount, options.BackgroundColor, options.ForegroundLayer); - var semaphore = GetLock(cacheFilePath); - - await semaphore.WaitAsync().ConfigureAwait(false); - var imageProcessingLockTaken = false; try @@ -251,15 +246,20 @@ namespace Emby.Drawing var newHeight = Convert.ToInt32(newSize.Height); _fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); + var tmpPath = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")); + _fileSystem.CreateDirectory(Path.GetDirectoryName(tmpPath)); await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); imageProcessingLockTaken = true; - _imageEncoder.EncodeImage(originalImagePath, cacheFilePath, AutoOrient(options.Item), newWidth, newHeight, quality, options, outputFormat); + _imageEncoder.EncodeImage(originalImagePath, tmpPath, AutoOrient(options.Item), newWidth, newHeight, quality, options, outputFormat); + CopyFile(tmpPath, cacheFilePath); + + return new Tuple(tmpPath, GetMimeType(outputFormat, cacheFilePath), _fileSystem.GetLastWriteTimeUtc(tmpPath)); } - return new Tuple(cacheFilePath, GetMimeType(outputFormat, cacheFilePath)); + return new Tuple(cacheFilePath, GetMimeType(outputFormat, cacheFilePath), _fileSystem.GetLastWriteTimeUtc(cacheFilePath)); } catch (Exception ex) { @@ -267,7 +267,7 @@ namespace Emby.Drawing _logger.ErrorException("Error encoding image", ex); // Just spit out the original file if all the options are default - return new Tuple(originalImagePath, MimeTypes.GetMimeType(originalImagePath)); + return new Tuple(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified); } finally { @@ -275,8 +275,18 @@ namespace Emby.Drawing { _imageProcessingSemaphore.Release(); } + } + } + + private void CopyFile(string src, string destination) + { + try + { + File.Copy(src, destination, true); + } + catch + { - semaphore.Release(); } } @@ -412,14 +422,9 @@ namespace Emby.Drawing var croppedImagePath = GetCachePath(CroppedWhitespaceImageCachePath, name, Path.GetExtension(originalImagePath)); - var semaphore = GetLock(croppedImagePath); - - await semaphore.WaitAsync().ConfigureAwait(false); - // Check again in case of contention if (_fileSystem.FileExists(croppedImagePath)) { - semaphore.Release(); return GetResult(croppedImagePath); } @@ -428,11 +433,15 @@ namespace Emby.Drawing try { _fileSystem.CreateDirectory(Path.GetDirectoryName(croppedImagePath)); + var tmpPath = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")); + _fileSystem.CreateDirectory(Path.GetDirectoryName(tmpPath)); await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); imageProcessingLockTaken = true; - _imageEncoder.CropWhiteSpace(originalImagePath, croppedImagePath); + _imageEncoder.CropWhiteSpace(originalImagePath, tmpPath); + CopyFile(tmpPath, croppedImagePath); + return GetResult(tmpPath); } catch (NotImplementedException) { @@ -452,11 +461,7 @@ namespace Emby.Drawing { _imageProcessingSemaphore.Release(); } - - semaphore.Release(); } - - return GetResult(croppedImagePath); } private Tuple GetResult(string path) diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index a549c44bc..5866ad15b 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -638,6 +638,7 @@ namespace MediaBrowser.Api.Images CacheDuration = cacheDuration, ResponseHeaders = headers, ContentType = imageResult.Item2, + DateLastModified = imageResult.Item3, IsHeadRequest = isHeadRequest, Path = imageResult.Item1, diff --git a/MediaBrowser.Controller/Drawing/IImageProcessor.cs b/MediaBrowser.Controller/Drawing/IImageProcessor.cs index d42a04f2e..19f391b4a 100644 --- a/MediaBrowser.Controller/Drawing/IImageProcessor.cs +++ b/MediaBrowser.Controller/Drawing/IImageProcessor.cs @@ -84,7 +84,7 @@ namespace MediaBrowser.Controller.Drawing /// /// The options. /// Task. - Task> ProcessImage(ImageProcessingOptions options); + Task> ProcessImage(ImageProcessingOptions options); /// /// Gets the enhanced image. diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index c520e43b8..c0a2a5eb3 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -331,7 +331,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer options.ContentType = MimeTypes.GetMimeType(path); } - options.DateLastModified = _fileSystem.GetLastWriteTimeUtc(path); + if (!options.DateLastModified.HasValue) + { + options.DateLastModified = _fileSystem.GetLastWriteTimeUtc(path); + } + var cacheKey = path + options.DateLastModified.Value.Ticks; options.CacheKey = cacheKey.GetMD5(); -- cgit v1.2.3 From 794b13b8167530f4a0b083fba414a332b723e594 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 17 Jul 2016 12:59:50 -0400 Subject: update suggestions --- MediaBrowser.Model/Dto/BaseItemDto.cs | 2 ++ MediaBrowser.Server.Implementations/Dto/DtoService.cs | 1 + MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 5be87ae4a..8ca1dfcb1 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -114,6 +114,8 @@ namespace MediaBrowser.Model.Dto /// The synchronize percent. public double? SyncPercent { get; set; } + public string Container { get; set; } + /// /// Gets or sets the DVD season number. /// diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 975e292f0..616625bc9 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -893,6 +893,7 @@ namespace MediaBrowser.Server.Implementations.Dto dto.LockData = item.IsLocked; dto.ForcedSortName = item.ForcedSortName; } + dto.Container = item.Container; var hasBudget = item as IHasBudget; if (hasBudget != null) diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index ca5742edd..a33e4f3e4 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -2144,7 +2144,7 @@ namespace MediaBrowser.Server.Implementations.Persistence { if (query.User != null) { - query.SortBy = new[] { "SimilarityScore", ItemSortBy.IsPlayed, ItemSortBy.Random }; + query.SortBy = new[] { ItemSortBy.IsPlayed, "SimilarityScore", ItemSortBy.Random }; } else { -- cgit v1.2.3