fix scanning of new libraries
This commit is contained in:
parent
c418f94c98
commit
8bc4d49c89
|
@ -194,7 +194,6 @@ namespace Emby.Server.Implementations.Data
|
|||
using (var statement = connection.PrepareStatement("select ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from FileOrganizerResults where ResultId=@ResultId"))
|
||||
{
|
||||
statement.TryBind("@ResultId", id.ToGuidParamValue());
|
||||
statement.MoveNext();
|
||||
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
|
|
|
@ -638,25 +638,30 @@ namespace Emby.Server.Implementations.Data
|
|||
|
||||
CheckDisposed();
|
||||
|
||||
var tuples = new List<Tuple<BaseItem, List<Guid>>>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
var ancestorIds = item.SupportsAncestors ?
|
||||
item.GetAncestorIds().Distinct().ToList() :
|
||||
null;
|
||||
|
||||
tuples.Add(new Tuple<BaseItem, List<Guid>>(item, ancestorIds));
|
||||
}
|
||||
|
||||
using (var connection = CreateConnection())
|
||||
{
|
||||
using (WriteLock.Write())
|
||||
{
|
||||
connection.RunInTransaction(db =>
|
||||
{
|
||||
SaveItemsInTranscation(db, items);
|
||||
SaveItemsInTranscation(db, tuples);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveItemsInTranscation(IDatabaseConnection db, List<BaseItem> items)
|
||||
private void SaveItemsInTranscation(IDatabaseConnection db, List<Tuple<BaseItem, List<Guid>>> tuples)
|
||||
{
|
||||
if (items == null)
|
||||
{
|
||||
throw new ArgumentNullException("items");
|
||||
}
|
||||
|
||||
var requiresReset = false;
|
||||
|
||||
using (var saveItemStatement = db.PrepareStatement(GetSaveItemCommandText()))
|
||||
|
@ -665,19 +670,21 @@ namespace Emby.Server.Implementations.Data
|
|||
{
|
||||
using (var updateAncestorsStatement = db.PrepareStatement("insert into AncestorIds (ItemId, AncestorId, AncestorIdText) values (@ItemId, @AncestorId, @AncestorIdText)"))
|
||||
{
|
||||
foreach (var item in items)
|
||||
foreach (var tuple in tuples)
|
||||
{
|
||||
if (requiresReset)
|
||||
{
|
||||
saveItemStatement.Reset();
|
||||
}
|
||||
|
||||
var item = tuple.Item1;
|
||||
|
||||
SaveItem(item, saveItemStatement);
|
||||
//Logger.Debug(_saveItemCommand.CommandText);
|
||||
|
||||
if (item.SupportsAncestors)
|
||||
{
|
||||
UpdateAncestors(item.Id, item.GetAncestorIds().Distinct().ToList(), db, deleteAncestorsStatement, updateAncestorsStatement);
|
||||
UpdateAncestors(item.Id, tuple.Item2, db, deleteAncestorsStatement, updateAncestorsStatement);
|
||||
}
|
||||
|
||||
UpdateItemValues(item.Id, GetItemValuesToSave(item), db);
|
||||
|
@ -802,7 +809,7 @@ namespace Emby.Server.Implementations.Data
|
|||
saveItemStatement.TryBind("@IsHD", item.IsHD);
|
||||
saveItemStatement.TryBind("@ExternalEtag", item.ExternalEtag);
|
||||
|
||||
if (item.DateLastRefreshed == default(DateTime))
|
||||
if (item.DateLastRefreshed != default(DateTime))
|
||||
{
|
||||
saveItemStatement.TryBind("@DateLastRefreshed", item.DateLastRefreshed);
|
||||
}
|
||||
|
@ -811,9 +818,9 @@ namespace Emby.Server.Implementations.Data
|
|||
saveItemStatement.TryBindNull("@DateLastRefreshed");
|
||||
}
|
||||
|
||||
if (item.DateLastSaved == default(DateTime))
|
||||
if (item.DateLastSaved != default(DateTime))
|
||||
{
|
||||
saveItemStatement.TryBind("@DateLastSaved", item.DateLastRefreshed);
|
||||
saveItemStatement.TryBind("@DateLastSaved", item.DateLastSaved);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -948,7 +955,7 @@ namespace Emby.Server.Implementations.Data
|
|||
var hasSeries = item as IHasSeries;
|
||||
if (hasSeries != null)
|
||||
{
|
||||
saveItemStatement.TryBind("@SeriesName", hasSeries.FindSeriesName());
|
||||
saveItemStatement.TryBind("@SeriesName", hasSeries.SeriesName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -960,8 +967,8 @@ namespace Emby.Server.Implementations.Data
|
|||
var episode = item as Episode;
|
||||
if (episode != null)
|
||||
{
|
||||
saveItemStatement.TryBind("@SeasonName", episode.FindSeasonName());
|
||||
saveItemStatement.TryBind("@SeasonId", episode.FindSeasonId());
|
||||
saveItemStatement.TryBind("@SeasonName", episode.SeasonName);
|
||||
saveItemStatement.TryBind("@SeasonId", episode.SeasonId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -971,8 +978,8 @@ namespace Emby.Server.Implementations.Data
|
|||
|
||||
if (hasSeries != null)
|
||||
{
|
||||
saveItemStatement.TryBind("@SeriesId", hasSeries.FindSeriesId());
|
||||
saveItemStatement.TryBind("@SeriesSortName", hasSeries.FindSeriesSortName());
|
||||
saveItemStatement.TryBind("@SeriesId", hasSeries.SeriesId);
|
||||
saveItemStatement.TryBind("@SeriesSortName", hasSeries.SeriesSortName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -25,10 +25,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||
{
|
||||
_cancellationToken = cancellationToken;
|
||||
|
||||
byte[] buffer = new byte[BufferSize];
|
||||
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
byte[] buffer = new byte[BufferSize];
|
||||
|
||||
var bytesRead = await source.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (bytesRead > 0)
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||
|
||||
public Action<QueueStream> OnFinished { get; set; }
|
||||
private readonly ILogger _logger;
|
||||
private bool _isActive;
|
||||
|
||||
public QueueStream(Stream outputStream, ILogger logger)
|
||||
{
|
||||
|
@ -29,7 +30,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||
|
||||
public void Queue(byte[] bytes)
|
||||
{
|
||||
_queue.Enqueue(bytes);
|
||||
if (_isActive)
|
||||
{
|
||||
_queue.Enqueue(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
public void Start(CancellationToken cancellationToken)
|
||||
|
@ -57,6 +61,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||
{
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
_isActive = true;
|
||||
|
||||
var bytes = Dequeue();
|
||||
if (bytes != null)
|
||||
{
|
||||
|
@ -83,6 +89,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||
}
|
||||
finally
|
||||
{
|
||||
_isActive = false;
|
||||
|
||||
if (OnFinished != null)
|
||||
{
|
||||
OnFinished(this);
|
||||
|
|
|
@ -418,6 +418,11 @@ namespace MediaBrowser.Providers.Manager
|
|||
// If any remote providers changed, run them all so that priorities can be honored
|
||||
if (i is IRemoteMetadataProvider)
|
||||
{
|
||||
if (options.MetadataRefreshMode == MetadataRefreshMode.ValidationOnly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return anyRemoteProvidersChanged;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,40 +20,39 @@ namespace MediaBrowser.Providers.TV
|
|||
{
|
||||
var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false);
|
||||
|
||||
if (updateType <= ItemUpdateType.None)
|
||||
var seriesName = item.FindSeriesName();
|
||||
if (!string.Equals(item.SeriesName, seriesName, StringComparison.Ordinal))
|
||||
{
|
||||
if (!string.Equals(item.SeriesName, item.FindSeriesName(), StringComparison.Ordinal))
|
||||
{
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
item.SeriesName = seriesName;
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
if (updateType <= ItemUpdateType.None)
|
||||
|
||||
var seriesSortName = item.FindSeriesSortName();
|
||||
if (!string.Equals(item.SeriesSortName, seriesSortName, StringComparison.Ordinal))
|
||||
{
|
||||
if (!string.Equals(item.SeriesSortName, item.FindSeriesSortName(), StringComparison.Ordinal))
|
||||
{
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
item.SeriesSortName = seriesSortName;
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
if (updateType <= ItemUpdateType.None)
|
||||
|
||||
var seasonName = item.FindSeasonName();
|
||||
if (!string.Equals(item.SeasonName, seasonName, StringComparison.Ordinal))
|
||||
{
|
||||
if (!string.Equals(item.SeasonName, item.FindSeasonName(), StringComparison.Ordinal))
|
||||
{
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
item.SeasonName = seasonName;
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
if (updateType <= ItemUpdateType.None)
|
||||
|
||||
var seriesId = item.FindSeriesId();
|
||||
if (item.SeriesId != seriesId)
|
||||
{
|
||||
if (item.SeriesId != item.FindSeriesId())
|
||||
{
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
item.SeriesId = seriesId;
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
if (updateType <= ItemUpdateType.None)
|
||||
|
||||
var seasonId = item.FindSeasonId();
|
||||
if (item.SeasonId != seasonId)
|
||||
{
|
||||
if (item.SeasonId != item.FindSeasonId())
|
||||
{
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
item.SeasonId = seasonId;
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
|
||||
return updateType;
|
||||
|
|
|
@ -37,16 +37,24 @@ namespace MediaBrowser.Providers.TV
|
|||
updateType |= SaveIsVirtualItem(item, episodes);
|
||||
}
|
||||
|
||||
if (!string.Equals(item.SeriesName, item.FindSeriesName(), StringComparison.Ordinal))
|
||||
var seriesName = item.FindSeriesName();
|
||||
if (!string.Equals(item.SeriesName, seriesName, StringComparison.Ordinal))
|
||||
{
|
||||
item.SeriesName = seriesName;
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
if (!string.Equals(item.SeriesSortName, item.FindSeriesSortName(), StringComparison.Ordinal))
|
||||
|
||||
var seriesSortName = item.FindSeriesSortName();
|
||||
if (!string.Equals(item.SeriesSortName, seriesSortName, StringComparison.Ordinal))
|
||||
{
|
||||
item.SeriesSortName = seriesSortName;
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
if (item.SeriesId != item.FindSeriesId())
|
||||
|
||||
var seriesId = item.FindSeriesId();
|
||||
if (item.SeriesId != seriesId)
|
||||
{
|
||||
item.SeriesId = seriesId;
|
||||
updateType |= ItemUpdateType.MetadataImport;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user