aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-11-17 13:24:40 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-11-17 13:24:40 -0500
commit2ee91249e54b9346823c52bcea7e2a770b04e5c1 (patch)
tree34ffdd929f95f502e858fe10af1949dfc3e68217
parent5013fddc2db5262c2297dce01fb89383ef5dcb27 (diff)
revert channel manager changes
-rw-r--r--MediaBrowser.Server.Implementations/Channels/ChannelManager.cs75
1 files changed, 30 insertions, 45 deletions
diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs
index 26fd1a01d..ba759dcb9 100644
--- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs
+++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs
@@ -104,11 +104,6 @@ namespace MediaBrowser.Server.Implementations.Channels
.OrderBy(i => i.Name);
}
- public IEnumerable<Guid> GetInstalledChannelIds()
- {
- return GetAllChannels().Select(i => GetInternalChannelId(i.Name));
- }
-
public Task<QueryResult<Channel>> GetChannelsInternal(ChannelQuery query, CancellationToken cancellationToken)
{
var user = string.IsNullOrWhiteSpace(query.UserId)
@@ -413,15 +408,25 @@ namespace MediaBrowser.Server.Implementations.Channels
private async Task<Channel> GetChannel(IChannel channelInfo, CancellationToken cancellationToken)
{
- var parentFolder = await GetInternalChannelFolder(cancellationToken).ConfigureAwait(false);
- var parentFolderId = parentFolder.Id;
-
var id = GetInternalChannelId(channelInfo.Name);
var path = Channel.GetInternalMetadataPath(_config.ApplicationPaths.InternalMetadataPath, id);
var isNew = false;
- var forceUpdate = false;
+
+ if (!_fileSystem.DirectoryExists(path))
+ {
+ _logger.Debug("Creating directory {0}", path);
+
+ _fileSystem.CreateDirectory(path);
+
+ if (!_fileSystem.DirectoryExists(path))
+ {
+ throw new IOException("Path not created: " + path);
+ }
+
+ isNew = true;
+ }
var item = _libraryManager.GetItemById(id) as Channel;
var channelId = channelInfo.Name.GetMD5().ToString("N");
@@ -433,29 +438,18 @@ namespace MediaBrowser.Server.Implementations.Channels
Name = channelInfo.Name,
Id = id,
DateCreated = _fileSystem.GetCreationTimeUtc(path),
- DateModified = _fileSystem.GetLastWriteTimeUtc(path)
+ DateModified = _fileSystem.GetLastWriteTimeUtc(path),
+ Path = path,
+ ChannelId = channelId
};
isNew = true;
}
- if (!string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase))
- {
- isNew = true;
- }
- item.Path = path;
-
if (!string.Equals(item.ChannelId, channelId, StringComparison.OrdinalIgnoreCase))
{
- forceUpdate = true;
- }
- item.ChannelId = channelId;
-
- if (item.ParentId != parentFolderId)
- {
- forceUpdate = true;
+ isNew = true;
}
- item.ParentId = parentFolderId;
item.OfficialRating = GetOfficialRating(channelInfo.ParentalRating);
item.Overview = channelInfo.Description;
@@ -465,17 +459,13 @@ namespace MediaBrowser.Server.Implementations.Channels
{
item.Name = channelInfo.Name;
}
-
- if (isNew)
+
+ await item.RefreshMetadata(new MetadataRefreshOptions(_fileSystem)
{
- await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
- }
- else if (forceUpdate)
- {
- await item.UpdateToRepository(ItemUpdateType.None, cancellationToken).ConfigureAwait(false);
- }
+ ForceSave = isNew
+
+ }, cancellationToken);
- await item.RefreshMetadata(new MetadataRefreshOptions(_fileSystem), cancellationToken);
return item;
}
@@ -1235,7 +1225,6 @@ namespace MediaBrowser.Server.Implementations.Channels
{
BaseItem item;
bool isNew;
- bool forceUpdate = false;
if (info.Type == ChannelItemType.Folder)
{
@@ -1265,6 +1254,7 @@ namespace MediaBrowser.Server.Implementations.Channels
item.ProductionYear = info.ProductionYear;
item.ProviderIds = info.ProviderIds;
item.OfficialRating = info.OfficialRating;
+
item.DateCreated = info.DateCreated ?? DateTime.UtcNow;
}
@@ -1272,17 +1262,16 @@ namespace MediaBrowser.Server.Implementations.Channels
channelItem.ChannelId = internalChannelId.ToString("N");
- if (item.ParentId != internalChannelId)
+ if (!string.Equals(channelItem.ExternalId, info.Id, StringComparison.OrdinalIgnoreCase))
{
- forceUpdate = true;
+ isNew = true;
}
- item.ParentId = internalChannelId;
+ channelItem.ExternalId = info.Id;
- if (!string.Equals(channelItem.ExternalId, info.Id, StringComparison.OrdinalIgnoreCase))
+ if (isNew)
{
- forceUpdate = true;
+ channelItem.Tags = info.Tags;
}
- channelItem.ExternalId = info.Id;
var channelMediaItem = item as IChannelMediaItem;
@@ -1297,7 +1286,7 @@ namespace MediaBrowser.Server.Implementations.Channels
item.Path = mediaSource == null ? null : mediaSource.Path;
}
- if (!string.IsNullOrWhiteSpace(info.ImageUrl) && !item.HasImage(ImageType.Primary))
+ if (!string.IsNullOrWhiteSpace(info.ImageUrl))
{
item.SetImagePath(ImageType.Primary, info.ImageUrl);
}
@@ -1311,10 +1300,6 @@ namespace MediaBrowser.Server.Implementations.Channels
await _libraryManager.UpdatePeople(item, info.People ?? new List<PersonInfo>()).ConfigureAwait(false);
}
}
- else if (forceUpdate)
- {
- await item.UpdateToRepository(ItemUpdateType.None, cancellationToken).ConfigureAwait(false);
- }
return item;
}