From 1f1eab209a289a0ad8ba37f49caf272a6fd9c104 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 27 May 2013 18:42:32 -0400 Subject: [PATCH] reduce db access from library manager --- .../Library/LibraryManager.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index cf5d75bb77..f9c8e9a31c 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -705,12 +705,16 @@ namespace MediaBrowser.Server.Implementations.Library BaseItem obj; - if (forceCreation || !_itemsByName.TryGetValue(key, out obj)) + if (!_itemsByName.TryGetValue(key, out obj)) { obj = await CreateItemByName(path, name, cancellationToken, allowSlowProviders).ConfigureAwait(false); _itemsByName.AddOrUpdate(key, obj, (keyName, oldValue) => obj); } + else if (forceCreation) + { + await obj.RefreshMetadata(cancellationToken, false, allowSlowProviders: allowSlowProviders).ConfigureAwait(false); + } return obj as T; }