aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/Studio.cs
diff options
context:
space:
mode:
authorhatharry <hatharry@hotmail.com>2016-08-28 12:51:32 +0000
committerGitHub <noreply@github.com>2016-08-28 12:51:32 +0000
commitc974641a352685b2e6595dd7b291843c8e6364ac (patch)
tree2e6ca83c4d08c5b676e12edae947e635d290bc3f /MediaBrowser.Controller/Entities/Studio.cs
parentf21f9923de6291aaf985f32dbbbaddbb26d07fb1 (diff)
parent81765ff29f624fd34e1abe3c7bb8149bbb001aef (diff)
Merge pull request #22 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Controller/Entities/Studio.cs')
-rw-r--r--MediaBrowser.Controller/Entities/Studio.cs51
1 files changed, 45 insertions, 6 deletions
diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs
index 762798b553..04b09b7442 100644
--- a/MediaBrowser.Controller/Entities/Studio.cs
+++ b/MediaBrowser.Controller/Entities/Studio.cs
@@ -18,13 +18,9 @@ namespace MediaBrowser.Controller.Entities
list.Insert(0, GetType().Name + "-" + (Name ?? string.Empty).RemoveDiacritics());
return list;
}
-
- public override string PresentationUniqueKey
+ public override string CreatePresentationUniqueKey()
{
- get
- {
- return GetUserDataKeys()[0];
- }
+ return GetUserDataKeys()[0];
}
/// <summary>
@@ -89,5 +85,48 @@ namespace MediaBrowser.Controller.Entities
return false;
}
}
+
+ public static string GetPath(string name, bool normalizeName = true)
+ {
+ // Trim the period at the end because windows will have a hard time with that
+ var validName = normalizeName ?
+ FileSystem.GetValidFilename(name).Trim().TrimEnd('.') :
+ name;
+
+ return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.StudioPath, validName);
+ }
+
+ private string GetRebasedPath()
+ {
+ return GetPath(System.IO.Path.GetFileName(Path), false);
+ }
+
+ public override bool RequiresRefresh()
+ {
+ var newPath = GetRebasedPath();
+ if (!string.Equals(Path, newPath, StringComparison.Ordinal))
+ {
+ Logger.Debug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath);
+ return true;
+ }
+ return base.RequiresRefresh();
+ }
+
+ /// <summary>
+ /// This is called before any metadata refresh and returns true or false indicating if changes were made
+ /// </summary>
+ public override bool BeforeMetadataRefresh()
+ {
+ var hasChanges = base.BeforeMetadataRefresh();
+
+ var newPath = GetRebasedPath();
+ if (!string.Equals(Path, newPath, StringComparison.Ordinal))
+ {
+ Path = newPath;
+ hasChanges = true;
+ }
+
+ return hasChanges;
+ }
}
}