diff --git a/Emby.Common.Implementations/IO/ManagedFileSystem.cs b/Emby.Common.Implementations/IO/ManagedFileSystem.cs index 6317fc08b..bfc316d3f 100644 --- a/Emby.Common.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Common.Implementations/IO/ManagedFileSystem.cs @@ -408,13 +408,13 @@ namespace Emby.Common.Implementations.IO { if (isHidden) { - FileAttributes attributes = File.GetAttributes(path); - attributes = RemoveAttribute(attributes, FileAttributes.Hidden); - File.SetAttributes(path, attributes); + File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden); } else { - File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden); + FileAttributes attributes = File.GetAttributes(path); + attributes = RemoveAttribute(attributes, FileAttributes.Hidden); + File.SetAttributes(path, attributes); } } } diff --git a/Emby.Common.Implementations/Serialization/XmlSerializer.cs b/Emby.Common.Implementations/Serialization/XmlSerializer.cs index ca162e868..aea63a57e 100644 --- a/Emby.Common.Implementations/Serialization/XmlSerializer.cs +++ b/Emby.Common.Implementations/Serialization/XmlSerializer.cs @@ -51,7 +51,6 @@ namespace Emby.Common.Implementations.Serialization /// The writer. private void SerializeToWriter(object obj, XmlWriter writer) { - //writer.Formatting = Formatting.Indented; var netSerializer = GetSerializer(obj.GetType()); netSerializer.Serialize(writer, obj); } @@ -78,10 +77,18 @@ namespace Emby.Common.Implementations.Serialization /// The stream. public void SerializeToStream(object obj, Stream stream) { - using (var writer = XmlWriter.Create(stream)) +#if NET46 + using (var writer = new XmlTextWriter(stream, null)) + { + writer.Formatting = System.Xml.Formatting.Indented; + SerializeToWriter(obj, writer); + } +#else + using (var writer = XmlWriter.Create(stream)) { SerializeToWriter(obj, writer); } +#endif } /// diff --git a/Emby.Drawing/Emby.Drawing.csproj b/Emby.Drawing/Emby.Drawing.csproj index 5c0870d3c..a883d0649 100644 --- a/Emby.Drawing/Emby.Drawing.csproj +++ b/Emby.Drawing/Emby.Drawing.csproj @@ -44,8 +44,8 @@ - - ..\ThirdParty\taglib\taglib-sharp.dll + + ..\ThirdParty\taglib\TagLib.Portable.dll diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 3235b7efa..aa1805871 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -21,6 +21,8 @@ using MediaBrowser.Common.IO; using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Net; +using TagLib; +using File = System.IO.File; namespace Emby.Drawing { @@ -578,7 +580,7 @@ namespace Emby.Drawing { try { - using (var file = TagLib.File.Create(path)) + using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(path), _fileSystem.OpenRead(path), null))) { var image = file as TagLib.Image.File; @@ -780,40 +782,38 @@ namespace Emby.Drawing // All enhanced images are saved as png to allow transparency var enhancedImagePath = GetCachePath(EnhancedImageCachePath, cacheGuid + ".png"); - var semaphore = GetLock(enhancedImagePath); - - await semaphore.WaitAsync().ConfigureAwait(false); - // Check again in case of contention if (_fileSystem.FileExists(enhancedImagePath)) { - semaphore.Release(); return enhancedImagePath; } - var imageProcessingLockTaken = false; + _fileSystem.CreateDirectory(Path.GetDirectoryName(enhancedImagePath)); + + var tmpPath = Path.Combine(_appPaths.TempDirectory, Path.ChangeExtension(Guid.NewGuid().ToString(), Path.GetExtension(enhancedImagePath))); + _fileSystem.CreateDirectory(Path.GetDirectoryName(tmpPath)); + + await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); try { - _fileSystem.CreateDirectory(Path.GetDirectoryName(enhancedImagePath)); + await ExecuteImageEnhancers(supportedEnhancers, originalImagePath, tmpPath, item, imageType, imageIndex).ConfigureAwait(false); - await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); - - imageProcessingLockTaken = true; - - await ExecuteImageEnhancers(supportedEnhancers, originalImagePath, enhancedImagePath, item, imageType, imageIndex).ConfigureAwait(false); + try + { + File.Copy(tmpPath, enhancedImagePath, true); + } + catch + { + + } } finally { - if (imageProcessingLockTaken) - { - _imageProcessingSemaphore.Release(); - } - - semaphore.Release(); + _imageProcessingSemaphore.Release(); } - return enhancedImagePath; + return tmpPath; } /// @@ -838,21 +838,6 @@ namespace Emby.Drawing } } - /// - /// The _semaphoreLocks - /// - private readonly ConcurrentDictionary _semaphoreLocks = new ConcurrentDictionary(); - - /// - /// Gets the lock. - /// - /// The filename. - /// System.Object. - private SemaphoreSlim GetLock(string filename) - { - return _semaphoreLocks.GetOrAdd(filename, key => new SemaphoreSlim(1, 1)); - } - /// /// Gets the cache path. /// diff --git a/Emby.Photos/Emby.Photos.csproj b/Emby.Photos/Emby.Photos.csproj index efc15519f..ed126a41c 100644 --- a/Emby.Photos/Emby.Photos.csproj +++ b/Emby.Photos/Emby.Photos.csproj @@ -9,9 +9,10 @@ Properties Emby.Photos Emby.Photos - v4.6 512 - + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile7 + v4.5 true @@ -31,16 +32,8 @@ 4 - - - - - - - - - - ..\ThirdParty\taglib\taglib-sharp.dll + + ..\ThirdParty\taglib\TagLib.Portable.dll @@ -61,7 +54,7 @@ MediaBrowser.Model - +