Merge pull request #1949 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-07-17 13:11:39 -04:00 committed by GitHub
commit dc264a2cf1
26 changed files with 169 additions and 205 deletions

View File

@ -163,7 +163,7 @@ namespace Emby.Drawing
return _imageEncoder.SupportedOutputFormats; return _imageEncoder.SupportedOutputFormats;
} }
public async Task<Tuple<string, string>> ProcessImage(ImageProcessingOptions options) public async Task<Tuple<string, string, DateTime>> ProcessImage(ImageProcessingOptions options)
{ {
if (options == null) if (options == null)
{ {
@ -178,14 +178,13 @@ namespace Emby.Drawing
} }
var originalImagePath = originalImage.Path; var originalImagePath = originalImage.Path;
var dateModified = originalImage.DateModified;
if (!_imageEncoder.SupportsImageEncoding) if (!_imageEncoder.SupportsImageEncoding)
{ {
return new Tuple<string, string>(originalImagePath, MimeTypes.GetMimeType(originalImagePath)); return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
} }
var dateModified = originalImage.DateModified;
if (options.CropWhiteSpace && _imageEncoder.SupportsImageEncoding) if (options.CropWhiteSpace && _imageEncoder.SupportsImageEncoding)
{ {
var tuple = await GetWhitespaceCroppedImage(originalImagePath, dateModified).ConfigureAwait(false); var tuple = await GetWhitespaceCroppedImage(originalImagePath, dateModified).ConfigureAwait(false);
@ -211,7 +210,7 @@ namespace Emby.Drawing
if (options.HasDefaultOptions(originalImagePath)) if (options.HasDefaultOptions(originalImagePath))
{ {
// Just spit out the original file if all the options are default // Just spit out the original file if all the options are default
return new Tuple<string, string>(originalImagePath, MimeTypes.GetMimeType(originalImagePath)); return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
} }
ImageSize? originalImageSize; ImageSize? originalImageSize;
@ -221,7 +220,7 @@ namespace Emby.Drawing
if (options.HasDefaultOptions(originalImagePath, originalImageSize.Value)) if (options.HasDefaultOptions(originalImagePath, originalImageSize.Value))
{ {
// Just spit out the original file if all the options are default // Just spit out the original file if all the options are default
return new Tuple<string, string>(originalImagePath, MimeTypes.GetMimeType(originalImagePath)); return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
} }
} }
catch catch
@ -235,10 +234,6 @@ namespace Emby.Drawing
var outputFormat = GetOutputFormat(options.SupportedOutputFormats[0]); 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 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; var imageProcessingLockTaken = false;
try try
@ -251,15 +246,20 @@ namespace Emby.Drawing
var newHeight = Convert.ToInt32(newSize.Height); var newHeight = Convert.ToInt32(newSize.Height);
_fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); _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); await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false);
imageProcessingLockTaken = true; 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<string, string, DateTime>(tmpPath, GetMimeType(outputFormat, cacheFilePath), _fileSystem.GetLastWriteTimeUtc(tmpPath));
} }
return new Tuple<string, string>(cacheFilePath, GetMimeType(outputFormat, cacheFilePath)); return new Tuple<string, string, DateTime>(cacheFilePath, GetMimeType(outputFormat, cacheFilePath), _fileSystem.GetLastWriteTimeUtc(cacheFilePath));
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -267,7 +267,7 @@ namespace Emby.Drawing
_logger.ErrorException("Error encoding image", ex); _logger.ErrorException("Error encoding image", ex);
// Just spit out the original file if all the options are default // Just spit out the original file if all the options are default
return new Tuple<string, string>(originalImagePath, MimeTypes.GetMimeType(originalImagePath)); return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
} }
finally finally
{ {
@ -275,8 +275,18 @@ namespace Emby.Drawing
{ {
_imageProcessingSemaphore.Release(); _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 croppedImagePath = GetCachePath(CroppedWhitespaceImageCachePath, name, Path.GetExtension(originalImagePath));
var semaphore = GetLock(croppedImagePath);
await semaphore.WaitAsync().ConfigureAwait(false);
// Check again in case of contention // Check again in case of contention
if (_fileSystem.FileExists(croppedImagePath)) if (_fileSystem.FileExists(croppedImagePath))
{ {
semaphore.Release();
return GetResult(croppedImagePath); return GetResult(croppedImagePath);
} }
@ -428,11 +433,15 @@ namespace Emby.Drawing
try try
{ {
_fileSystem.CreateDirectory(Path.GetDirectoryName(croppedImagePath)); _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); await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false);
imageProcessingLockTaken = true; imageProcessingLockTaken = true;
_imageEncoder.CropWhiteSpace(originalImagePath, croppedImagePath); _imageEncoder.CropWhiteSpace(originalImagePath, tmpPath);
CopyFile(tmpPath, croppedImagePath);
return GetResult(tmpPath);
} }
catch (NotImplementedException) catch (NotImplementedException)
{ {
@ -452,11 +461,7 @@ namespace Emby.Drawing
{ {
_imageProcessingSemaphore.Release(); _imageProcessingSemaphore.Release();
} }
semaphore.Release();
} }
return GetResult(croppedImagePath);
} }
private Tuple<string, DateTime> GetResult(string path) private Tuple<string, DateTime> GetResult(string path)

View File

@ -638,6 +638,7 @@ namespace MediaBrowser.Api.Images
CacheDuration = cacheDuration, CacheDuration = cacheDuration,
ResponseHeaders = headers, ResponseHeaders = headers,
ContentType = imageResult.Item2, ContentType = imageResult.Item2,
DateLastModified = imageResult.Item3,
IsHeadRequest = isHeadRequest, IsHeadRequest = isHeadRequest,
Path = imageResult.Item1, Path = imageResult.Item1,

View File

@ -108,11 +108,11 @@ namespace MediaBrowser.Api.Playback.Progressive
var eofCount = 0; var eofCount = 0;
long position = 0; long position = 0;
using (var fs = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, false)) using (var fs = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true))
{ {
while (eofCount < 15) while (eofCount < 15)
{ {
CopyToInternal(fs, outputStream, BufferSize); await CopyToInternal(fs, outputStream, BufferSize).ConfigureAwait(false);
var fsPosition = fs.Position; var fsPosition = fs.Position;
@ -138,11 +138,11 @@ namespace MediaBrowser.Api.Playback.Progressive
} }
} }
private void CopyToInternal(Stream source, Stream destination, int bufferSize) private async Task CopyToInternal(Stream source, Stream destination, int bufferSize)
{ {
var array = new byte[bufferSize]; var array = new byte[bufferSize];
int count; int count;
while ((count = source.Read(array, 0, array.Length)) != 0) while ((count = await source.ReadAsync(array, 0, array.Length).ConfigureAwait(false)) != 0)
{ {
//if (_job != null) //if (_job != null)
//{ //{
@ -168,7 +168,7 @@ namespace MediaBrowser.Api.Playback.Progressive
// } // }
//} //}
destination.Write(array, 0, count); await destination.WriteAsync(array, 0, count).ConfigureAwait(false);
_bytesWritten += count; _bytesWritten += count;

View File

@ -58,10 +58,10 @@ namespace MediaBrowser.Api.Reports
/// <summary> Gets the given request. </summary> /// <summary> Gets the given request. </summary>
/// <param name="request"> The request. </param> /// <param name="request"> The request. </param>
/// <returns> A Task&lt;object&gt; </returns> /// <returns> A Task&lt;object&gt; </returns>
public async Task<object> Get(GetActivityLogs request) public object Get(GetActivityLogs request)
{ {
request.DisplayType = "Screen"; request.DisplayType = "Screen";
ReportResult result = await GetReportActivities(request).ConfigureAwait(false); ReportResult result = GetReportActivities(request);
return ToOptimizedResult(result); return ToOptimizedResult(result);
} }
@ -104,7 +104,8 @@ namespace MediaBrowser.Api.Reports
return null; return null;
request.DisplayType = "Screen"; request.DisplayType = "Screen";
var reportResult = await GetReportResult(request); var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;
var reportResult = await GetReportResult(request, user);
return ToOptimizedResult(reportResult); return ToOptimizedResult(reportResult);
} }
@ -117,7 +118,8 @@ namespace MediaBrowser.Api.Reports
if (string.IsNullOrEmpty(request.IncludeItemTypes)) if (string.IsNullOrEmpty(request.IncludeItemTypes))
return null; return null;
request.DisplayType = "Screen"; request.DisplayType = "Screen";
var reportResult = await GetReportStatistic(request); var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;
var reportResult = await GetReportStatistic(request, user);
return ToOptimizedResult(reportResult); return ToOptimizedResult(reportResult);
} }
@ -150,6 +152,7 @@ namespace MediaBrowser.Api.Reports
headers["Content-Disposition"] = string.Format("attachment; filename=\"{0}\"", filename); headers["Content-Disposition"] = string.Format("attachment; filename=\"{0}\"", filename);
headers["Content-Encoding"] = "UTF-8"; headers["Content-Encoding"] = "UTF-8";
var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;
ReportResult result = null; ReportResult result = null;
switch (reportViewType) switch (reportViewType)
{ {
@ -157,12 +160,12 @@ namespace MediaBrowser.Api.Reports
case ReportViewType.ReportData: case ReportViewType.ReportData:
ReportIncludeItemTypes reportRowType = ReportHelper.GetRowType(request.IncludeItemTypes); ReportIncludeItemTypes reportRowType = ReportHelper.GetRowType(request.IncludeItemTypes);
ReportBuilder dataBuilder = new ReportBuilder(_libraryManager); ReportBuilder dataBuilder = new ReportBuilder(_libraryManager);
QueryResult<BaseItem> queryResult = await GetQueryResult(request).ConfigureAwait(false); QueryResult<BaseItem> queryResult = await GetQueryResult(request, user).ConfigureAwait(false);
result = dataBuilder.GetResult(queryResult.Items, request); result = dataBuilder.GetResult(queryResult.Items, request);
result.TotalRecordCount = queryResult.TotalRecordCount; result.TotalRecordCount = queryResult.TotalRecordCount;
break; break;
case ReportViewType.ReportActivities: case ReportViewType.ReportActivities:
result = await GetReportActivities(request).ConfigureAwait(false); result = GetReportActivities(request);
break; break;
} }
@ -177,23 +180,15 @@ namespace MediaBrowser.Api.Reports
break; break;
} }
object ro = ResultFactory.GetResult(returnResult, contentType, headers); return ResultFactory.GetResult(returnResult, contentType, headers);
return ro;
} }
#endregion #endregion
#region [Private Methods]
/// <summary> Gets items query. </summary>
/// <param name="request"> The request. </param>
/// <param name="user"> The user. </param>
/// <returns> The items query. </returns>
private InternalItemsQuery GetItemsQuery(BaseReportRequest request, User user) private InternalItemsQuery GetItemsQuery(BaseReportRequest request, User user)
{ {
var query = new InternalItemsQuery var query = new InternalItemsQuery(user)
{ {
User = user,
IsPlayed = request.IsPlayed, IsPlayed = request.IsPlayed,
MediaTypes = request.GetMediaTypes(), MediaTypes = request.GetMediaTypes(),
IncludeItemTypes = request.GetIncludeItemTypes(), IncludeItemTypes = request.GetIncludeItemTypes(),
@ -231,6 +226,7 @@ namespace MediaBrowser.Api.Reports
Tags = request.GetTags(), Tags = request.GetTags(),
OfficialRatings = request.GetOfficialRatings(), OfficialRatings = request.GetOfficialRatings(),
Genres = request.GetGenres(), Genres = request.GetGenres(),
GenreIds = request.GetGenreIds(),
Studios = request.GetStudios(), Studios = request.GetStudios(),
StudioIds = request.GetStudioIds(), StudioIds = request.GetStudioIds(),
Person = request.Person, Person = request.Person,
@ -245,9 +241,11 @@ namespace MediaBrowser.Api.Reports
MaxPlayers = request.MaxPlayers, MaxPlayers = request.MaxPlayers,
MinCommunityRating = request.MinCommunityRating, MinCommunityRating = request.MinCommunityRating,
MinCriticRating = request.MinCriticRating, MinCriticRating = request.MinCriticRating,
ParentId = string.IsNullOrWhiteSpace(request.ParentId) ? (Guid?)null : new Guid(request.ParentId),
ParentIndexNumber = request.ParentIndexNumber, ParentIndexNumber = request.ParentIndexNumber,
AiredDuringSeason = request.AiredDuringSeason, AiredDuringSeason = request.AiredDuringSeason,
AlbumArtistStartsWithOrGreater = request.AlbumArtistStartsWithOrGreater AlbumArtistStartsWithOrGreater = request.AlbumArtistStartsWithOrGreater,
EnableTotalRecordCount = request.EnableTotalRecordCount
}; };
if (!string.IsNullOrWhiteSpace(request.Ids)) if (!string.IsNullOrWhiteSpace(request.Ids))
@ -357,70 +355,86 @@ namespace MediaBrowser.Api.Reports
query.AlbumNames = request.Albums.Split('|'); query.AlbumNames = request.Albums.Split('|');
} }
if (request.HasQueryLimit == false)
{
query.StartIndex = null;
query.Limit = null;
}
return query; return query;
} }
/// <summary> Gets query result. </summary> private async Task<QueryResult<BaseItem>> GetQueryResult(BaseReportRequest request, User user)
/// <param name="request"> The request. </param>
/// <returns> The query result. </returns>
private async Task<QueryResult<BaseItem>> GetQueryResult(BaseReportRequest request)
{ {
// Placeholder in case needed later // all report queries currently need this because it's not being specified
request.Recursive = true; request.Recursive = true;
var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;
request.Fields = "MediaSources,DateCreated,Settings,Studios,SyncInfo,ItemCounts";
var parentItem = string.IsNullOrEmpty(request.ParentId) ?
(user == null ? _libraryManager.RootFolder : user.RootFolder) :
_libraryManager.GetItemById(request.ParentId);
var item = string.IsNullOrEmpty(request.ParentId) ? var item = string.IsNullOrEmpty(request.ParentId) ?
user == null ? _libraryManager.RootFolder : user.RootFolder : user == null ? _libraryManager.RootFolder : user.RootFolder :
parentItem; _libraryManager.GetItemById(request.ParentId);
IEnumerable<BaseItem> items; if (string.Equals(request.IncludeItemTypes, "Playlist", StringComparison.OrdinalIgnoreCase))
{
//item = user == null ? _libraryManager.RootFolder : user.RootFolder;
}
else if (string.Equals(request.IncludeItemTypes, "BoxSet", StringComparison.OrdinalIgnoreCase))
{
item = user == null ? _libraryManager.RootFolder : user.RootFolder;
}
// Default list type = children
var folder = item as Folder;
if (folder == null)
{
folder = user == null ? _libraryManager.RootFolder : _libraryManager.GetUserRootFolder();
}
if (!string.IsNullOrEmpty(request.Ids))
{
request.Recursive = true;
var query = GetItemsQuery(request, user);
var result = await folder.GetItems(query).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(request.SortBy))
{
var ids = query.ItemIds.ToList();
// Try to preserve order
result.Items = result.Items.OrderBy(i => ids.IndexOf(i.Id.ToString("N"))).ToArray();
}
return result;
}
if (request.Recursive) if (request.Recursive)
{ {
var result = await ((Folder)item).GetItems(GetItemsQuery(request, user)).ConfigureAwait(false); return await folder.GetItems(GetItemsQuery(request, user)).ConfigureAwait(false);
return result;
} }
else
{
if (user == null) if (user == null)
{ {
var result = await ((Folder)item).GetItems(GetItemsQuery(request, null)).ConfigureAwait(false); return await folder.GetItems(GetItemsQuery(request, null)).ConfigureAwait(false);
return result;
} }
var userRoot = item as UserRootFolder; var userRoot = item as UserRootFolder;
if (userRoot == null) if (userRoot == null)
{ {
var result = await ((Folder)item).GetItems(GetItemsQuery(request, user)).ConfigureAwait(false); return await folder.GetItems(GetItemsQuery(request, user)).ConfigureAwait(false);
return result;
} }
items = ((Folder)item).GetChildren(user, true); IEnumerable<BaseItem> items = folder.GetChildren(user, true);
var itemsArray = items.ToArray();
return new QueryResult<BaseItem>
{
Items = itemsArray,
TotalRecordCount = itemsArray.Length
};
} }
return new QueryResult<BaseItem> { Items = items.ToArray() }; #region [Private Methods]
}
/// <summary> Gets report activities. </summary> /// <summary> Gets report activities. </summary>
/// <param name="request"> The request. </param> /// <param name="request"> The request. </param>
/// <returns> The report activities. </returns> /// <returns> The report activities. </returns>
private Task<ReportResult> GetReportActivities(IReportsDownload request) private ReportResult GetReportActivities(IReportsDownload request)
{
return Task<ReportResult>.Run(() =>
{ {
DateTime? minDate = string.IsNullOrWhiteSpace(request.MinDate) ? DateTime? minDate = string.IsNullOrWhiteSpace(request.MinDate) ?
(DateTime?)null : (DateTime?)null :
@ -437,18 +451,15 @@ namespace MediaBrowser.Api.Reports
var result = builder.GetResult(queryResult, request); var result = builder.GetResult(queryResult, request);
result.TotalRecordCount = queryResult.TotalRecordCount; result.TotalRecordCount = queryResult.TotalRecordCount;
return result; return result;
});
} }
/// <summary> Gets report result. </summary> /// <summary> Gets report result. </summary>
/// <param name="request"> The request. </param> /// <param name="request"> The request. </param>
/// <returns> The report result. </returns> /// <returns> The report result. </returns>
private async Task<ReportResult> GetReportResult(GetItemReport request) private async Task<ReportResult> GetReportResult(GetItemReport request, User user)
{ {
ReportBuilder reportBuilder = new ReportBuilder(_libraryManager); ReportBuilder reportBuilder = new ReportBuilder(_libraryManager);
QueryResult<BaseItem> queryResult = await GetQueryResult(request).ConfigureAwait(false); QueryResult<BaseItem> queryResult = await GetQueryResult(request, user).ConfigureAwait(false);
ReportResult reportResult = reportBuilder.GetResult(queryResult.Items, request); ReportResult reportResult = reportBuilder.GetResult(queryResult.Items, request);
reportResult.TotalRecordCount = queryResult.TotalRecordCount; reportResult.TotalRecordCount = queryResult.TotalRecordCount;
@ -458,10 +469,10 @@ namespace MediaBrowser.Api.Reports
/// <summary> Gets report statistic. </summary> /// <summary> Gets report statistic. </summary>
/// <param name="request"> The request. </param> /// <param name="request"> The request. </param>
/// <returns> The report statistic. </returns> /// <returns> The report statistic. </returns>
private async Task<ReportStatResult> GetReportStatistic(GetReportStatistics request) private async Task<ReportStatResult> GetReportStatistic(GetReportStatistics request, User user)
{ {
ReportIncludeItemTypes reportRowType = ReportHelper.GetRowType(request.IncludeItemTypes); ReportIncludeItemTypes reportRowType = ReportHelper.GetRowType(request.IncludeItemTypes);
QueryResult<BaseItem> queryResult = await GetQueryResult(request).ConfigureAwait(false); QueryResult<BaseItem> queryResult = await GetQueryResult(request, user).ConfigureAwait(false);
ReportStatBuilder reportBuilder = new ReportStatBuilder(_libraryManager); ReportStatBuilder reportBuilder = new ReportStatBuilder(_libraryManager);
ReportStatResult reportResult = reportBuilder.GetResult(queryResult.Items, ReportHelper.GetRowType(request.IncludeItemTypes), request.TopItems ?? 5); ReportStatResult reportResult = reportBuilder.GetResult(queryResult.Items, ReportHelper.GetRowType(request.IncludeItemTypes), request.TopItems ?? 5);

View File

@ -101,7 +101,7 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null; var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;
var result = await GetItemsToSerialize(request, user).ConfigureAwait(false); var result = await GetQueryResult(request, user).ConfigureAwait(false);
if (result == null) if (result == null)
{ {
@ -135,7 +135,7 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
/// <param name="user">The user.</param> /// <param name="user">The user.</param>
/// <returns>IEnumerable{BaseItem}.</returns> /// <returns>IEnumerable{BaseItem}.</returns>
private async Task<QueryResult<BaseItem>> GetItemsToSerialize(GetItems request, User user) private async Task<QueryResult<BaseItem>> GetQueryResult(GetItems request, User user)
{ {
var item = string.IsNullOrEmpty(request.ParentId) ? var item = string.IsNullOrEmpty(request.ParentId) ?
user == null ? _libraryManager.RootFolder : user.RootFolder : user == null ? _libraryManager.RootFolder : user.RootFolder :

View File

@ -84,7 +84,7 @@ namespace MediaBrowser.Controller.Drawing
/// </summary> /// </summary>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
Task<Tuple<string, string>> ProcessImage(ImageProcessingOptions options); Task<Tuple<string, string, DateTime>> ProcessImage(ImageProcessingOptions options);
/// <summary> /// <summary>
/// Gets the enhanced image. /// Gets the enhanced image.

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Weavers> <Weavers>
<PropertyChanged />
</Weavers> </Weavers>

View File

@ -36,6 +36,8 @@
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<RestorePackages>true</RestorePackages> <RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -617,9 +619,6 @@
<Compile Include="..\MediaBrowser.Model\Extensions\FloatHelper.cs"> <Compile Include="..\MediaBrowser.Model\Extensions\FloatHelper.cs">
<Link>Extensions\FloatHelper.cs</Link> <Link>Extensions\FloatHelper.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\Extensions\IHasPropertyChangedEvent.cs">
<Link>Extensions\IHasPropertyChangedEvent.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Extensions\IntHelper.cs"> <Compile Include="..\MediaBrowser.Model\Extensions\IntHelper.cs">
<Link>Extensions\IntHelper.cs</Link> <Link>Extensions\IntHelper.cs</Link>
</Compile> </Compile>
@ -1233,13 +1232,6 @@
<PostBuildEvent> <PostBuildEvent>
</PostBuildEvent> </PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<Import Project="..\packages\Fody.1.29.2\build\portable-net+sl+win+wpa+wp\Fody.targets" Condition="Exists('..\packages\Fody.1.29.2\build\portable-net+sl+win+wpa+wp\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.1.29.2\build\portable-net+sl+win+wpa+wp\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.29.2\build\portable-net+sl+win+wpa+wp\Fody.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Fody" version="1.29.2" targetFramework="portable45-net45+win8+wp8+wpa81" developmentDependency="true" />
<package id="PropertyChanged.Fody" version="1.50.4" targetFramework="portable45-net45+win8+wp8+wpa81" developmentDependency="true" />
</packages>

View File

@ -591,9 +591,6 @@
<Compile Include="..\MediaBrowser.Model\Extensions\FloatHelper.cs"> <Compile Include="..\MediaBrowser.Model\Extensions\FloatHelper.cs">
<Link>Extensions\FloatHelper.cs</Link> <Link>Extensions\FloatHelper.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\Extensions\IHasPropertyChangedEvent.cs">
<Link>Extensions\IHasPropertyChangedEvent.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Extensions\IntHelper.cs"> <Compile Include="..\MediaBrowser.Model\Extensions\IntHelper.cs">
<Link>Extensions\IntHelper.cs</Link> <Link>Extensions\IntHelper.cs</Link>
</Compile> </Compile>

View File

@ -18,7 +18,7 @@ namespace MediaBrowser.Model.Dto
/// This holds information about a BaseItem in a format that is convenient for the client. /// This holds information about a BaseItem in a format that is convenient for the client.
/// </summary> /// </summary>
[DebuggerDisplay("Name = {Name}, ID = {Id}, Type = {Type}")] [DebuggerDisplay("Name = {Name}, ID = {Id}, Type = {Type}")]
public class BaseItemDto : IHasProviderIds, IHasPropertyChangedEvent, IItemDto, IHasServerId, IHasSyncInfo public class BaseItemDto : IHasProviderIds, IItemDto, IHasServerId, IHasSyncInfo
{ {
/// <summary> /// <summary>
/// Gets or sets the name. /// Gets or sets the name.
@ -114,6 +114,8 @@ namespace MediaBrowser.Model.Dto
/// <value>The synchronize percent.</value> /// <value>The synchronize percent.</value>
public double? SyncPercent { get; set; } public double? SyncPercent { get; set; }
public string Container { get; set; }
/// <summary> /// <summary>
/// Gets or sets the DVD season number. /// Gets or sets the DVD season number.
/// </summary> /// </summary>
@ -1109,11 +1111,6 @@ namespace MediaBrowser.Model.Dto
} }
} }
/// <summary>
/// Occurs when [property changed].
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary> /// <summary>
/// Gets or sets the program identifier. /// Gets or sets the program identifier.
/// </summary> /// </summary>

View File

@ -1,5 +1,4 @@
using MediaBrowser.Model.Extensions; using System.ComponentModel;
using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@ -9,7 +8,7 @@ namespace MediaBrowser.Model.Dto
/// This is used by the api to get information about a Person within a BaseItem /// This is used by the api to get information about a Person within a BaseItem
/// </summary> /// </summary>
[DebuggerDisplay("Name = {Name}, Role = {Role}, Type = {Type}")] [DebuggerDisplay("Name = {Name}, Role = {Role}, Type = {Type}")]
public class BaseItemPerson : IHasPropertyChangedEvent public class BaseItemPerson
{ {
/// <summary> /// <summary>
/// Gets or sets the name. /// Gets or sets the name.
@ -53,10 +52,5 @@ namespace MediaBrowser.Model.Dto
return PrimaryImageTag != null; return PrimaryImageTag != null;
} }
} }
/// <summary>
/// Occurs when [property changed].
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
} }
} }

View File

@ -1,7 +1,5 @@
using System.ComponentModel; using System.Diagnostics;
using System.Diagnostics;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Model.Dto namespace MediaBrowser.Model.Dto
{ {
@ -9,7 +7,7 @@ namespace MediaBrowser.Model.Dto
/// Class ChapterInfo /// Class ChapterInfo
/// </summary> /// </summary>
[DebuggerDisplay("Name = {Name}")] [DebuggerDisplay("Name = {Name}")]
public class ChapterInfoDto : IHasPropertyChangedEvent public class ChapterInfoDto
{ {
/// <summary> /// <summary>
/// Gets or sets the start position ticks. /// Gets or sets the start position ticks.
@ -38,7 +36,5 @@ namespace MediaBrowser.Model.Dto
{ {
get { return ImageTag != null; } get { return ImageTag != null; }
} }
public event PropertyChangedEventHandler PropertyChanged;
} }
} }

View File

@ -1,6 +1,5 @@
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Connect; using MediaBrowser.Model.Connect;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Users; using MediaBrowser.Model.Users;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
@ -13,7 +12,7 @@ namespace MediaBrowser.Model.Dto
/// Class UserDto /// Class UserDto
/// </summary> /// </summary>
[DebuggerDisplay("Name = {Name}, ID = {Id}, HasPassword = {HasPassword}")] [DebuggerDisplay("Name = {Name}, ID = {Id}, HasPassword = {HasPassword}")]
public class UserDto : IHasPropertyChangedEvent, IItemDto, IHasServerId public class UserDto : IItemDto, IHasServerId
{ {
/// <summary> /// <summary>
/// Gets or sets the name. /// Gets or sets the name.
@ -141,11 +140,6 @@ namespace MediaBrowser.Model.Dto
Policy = new UserPolicy(); Policy = new UserPolicy();
} }
/// <summary>
/// Occurs when [property changed].
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
public override string ToString() public override string ToString()
{ {
return Name ?? base.ToString(); return Name ?? base.ToString();

View File

@ -1,5 +1,4 @@
using MediaBrowser.Model.Extensions; using System;
using System;
using System.ComponentModel; using System.ComponentModel;
namespace MediaBrowser.Model.Dto namespace MediaBrowser.Model.Dto
@ -7,7 +6,7 @@ namespace MediaBrowser.Model.Dto
/// <summary> /// <summary>
/// Class UserItemDataDto /// Class UserItemDataDto
/// </summary> /// </summary>
public class UserItemDataDto : IHasPropertyChangedEvent public class UserItemDataDto
{ {
/// <summary> /// <summary>
/// Gets or sets the rating. /// Gets or sets the rating.
@ -74,7 +73,5 @@ namespace MediaBrowser.Model.Dto
/// </summary> /// </summary>
/// <value>The item identifier.</value> /// <value>The item identifier.</value>
public string ItemId { get; set; } public string ItemId { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
} }
} }

View File

@ -1,21 +1,14 @@
using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Drawing;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Model.Entities namespace MediaBrowser.Model.Entities
{ {
/// <summary> /// <summary>
/// Defines the display preferences for any item that supports them (usually Folders) /// Defines the display preferences for any item that supports them (usually Folders)
/// </summary> /// </summary>
public class DisplayPreferences : IHasPropertyChangedEvent public class DisplayPreferences
{ {
/// <summary>
/// Occurs when [property changed].
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary> /// <summary>
/// The image scale /// The image scale
/// </summary> /// </summary>

View File

@ -1,8 +0,0 @@
using System.ComponentModel;
namespace MediaBrowser.Model.Extensions
{
public interface IHasPropertyChangedEvent : INotifyPropertyChanged
{
}
}

View File

@ -1,17 +1,10 @@
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Extensions;
using System; using System;
using System.ComponentModel;
namespace MediaBrowser.Model.LiveTv namespace MediaBrowser.Model.LiveTv
{ {
public class BaseTimerInfoDto : IHasPropertyChangedEvent, IHasServerId public class BaseTimerInfoDto : IHasServerId
{ {
/// <summary>
/// Occurs when a property value changes.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary> /// <summary>
/// Id of the recording. /// Id of the recording.
/// </summary> /// </summary>

View File

@ -1,6 +1,5 @@
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Library; using MediaBrowser.Model.Library;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -13,7 +12,7 @@ namespace MediaBrowser.Model.LiveTv
/// Class ChannelInfoDto /// Class ChannelInfoDto
/// </summary> /// </summary>
[DebuggerDisplay("Name = {Name}, Number = {Number}")] [DebuggerDisplay("Name = {Name}, Number = {Number}")]
public class ChannelInfoDto : IHasPropertyChangedEvent, IItemDto, IHasServerId public class ChannelInfoDto : IItemDto, IHasServerId
{ {
/// <summary> /// <summary>
/// Gets or sets the name. /// Gets or sets the name.
@ -120,7 +119,5 @@ namespace MediaBrowser.Model.LiveTv
ImageTags = new Dictionary<ImageType, string>(); ImageTags = new Dictionary<ImageType, string>();
MediaSources = new List<MediaSourceInfo>(); MediaSources = new List<MediaSourceInfo>();
} }
public event PropertyChangedEventHandler PropertyChanged;
} }
} }

View File

@ -4,6 +4,11 @@ namespace MediaBrowser.Model.LiveTv
{ {
public class TimerInfoDto : BaseTimerInfoDto public class TimerInfoDto : BaseTimerInfoDto
{ {
public TimerInfoDto()
{
Type = "Timer";
}
/// <summary> /// <summary>
/// Gets or sets the status. /// Gets or sets the status.
/// </summary> /// </summary>
@ -22,6 +27,8 @@ namespace MediaBrowser.Model.LiveTv
/// <value>The external series timer identifier.</value> /// <value>The external series timer identifier.</value>
public string ExternalSeriesTimerId { get; set; } public string ExternalSeriesTimerId { get; set; }
public string Type { get; set; }
/// <summary> /// <summary>
/// Gets or sets the run time ticks. /// Gets or sets the run time ticks.
/// </summary> /// </summary>

View File

@ -229,7 +229,6 @@
<Compile Include="Entities\SortOrder.cs" /> <Compile Include="Entities\SortOrder.cs" />
<Compile Include="Events\GenericEventArgs.cs" /> <Compile Include="Events\GenericEventArgs.cs" />
<Compile Include="Extensions\DoubleHelper.cs" /> <Compile Include="Extensions\DoubleHelper.cs" />
<Compile Include="Extensions\IHasPropertyChangedEvent.cs" />
<Compile Include="Extensions\IntHelper.cs" /> <Compile Include="Extensions\IntHelper.cs" />
<Compile Include="Extensions\ListHelper.cs" /> <Compile Include="Extensions\ListHelper.cs" />
<Compile Include="Extensions\StringHelper.cs" /> <Compile Include="Extensions\StringHelper.cs" />

View File

@ -1,5 +1,4 @@
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Extensions;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -8,7 +7,7 @@ using System.Diagnostics;
namespace MediaBrowser.Model.Session namespace MediaBrowser.Model.Session
{ {
[DebuggerDisplay("Client = {Client}, Username = {UserName}")] [DebuggerDisplay("Client = {Client}, Username = {UserName}")]
public class SessionInfoDto : IHasPropertyChangedEvent public class SessionInfoDto
{ {
/// <summary> /// <summary>
/// Gets or sets the supported commands. /// Gets or sets the supported commands.
@ -116,8 +115,6 @@ namespace MediaBrowser.Model.Session
public TranscodingInfo TranscodingInfo { get; set; } public TranscodingInfo TranscodingInfo { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public SessionInfoDto() public SessionInfoDto()
{ {
AdditionalUsers = new List<SessionUserInfo>(); AdditionalUsers = new List<SessionUserInfo>();

View File

@ -893,6 +893,7 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.LockData = item.IsLocked; dto.LockData = item.IsLocked;
dto.ForcedSortName = item.ForcedSortName; dto.ForcedSortName = item.ForcedSortName;
} }
dto.Container = item.Container;
var hasBudget = item as IHasBudget; var hasBudget = item as IHasBudget;
if (hasBudget != null) if (hasBudget != null)

View File

@ -331,7 +331,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer
options.ContentType = MimeTypes.GetMimeType(path); options.ContentType = MimeTypes.GetMimeType(path);
} }
if (!options.DateLastModified.HasValue)
{
options.DateLastModified = _fileSystem.GetLastWriteTimeUtc(path); options.DateLastModified = _fileSystem.GetLastWriteTimeUtc(path);
}
var cacheKey = path + options.DateLastModified.Value.Ticks; var cacheKey = path + options.DateLastModified.Value.Ticks;
options.CacheKey = cacheKey.GetMD5(); options.CacheKey = cacheKey.GetMD5();

View File

@ -2144,7 +2144,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
{ {
if (query.User != null) if (query.User != null)
{ {
query.SortBy = new[] { "SimilarityScore", ItemSortBy.IsPlayed, ItemSortBy.Random }; query.SortBy = new[] { ItemSortBy.IsPlayed, "SimilarityScore", ItemSortBy.Random };
} }
else else
{ {

View File

@ -247,15 +247,18 @@ namespace MediaBrowser.Server.Implementations.Playlists
return; return;
} }
if (newIndex > oldIndex)
{
newIndex--;
}
var item = playlist.LinkedChildren[oldIndex]; var item = playlist.LinkedChildren[oldIndex];
playlist.LinkedChildren.Remove(item); playlist.LinkedChildren.Remove(item);
if (newIndex >= playlist.LinkedChildren.Count)
{
playlist.LinkedChildren.Add(item);
}
else
{
playlist.LinkedChildren.Insert(newIndex, item); playlist.LinkedChildren.Insert(newIndex, item);
}
await playlist.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); await playlist.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
} }