aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/Studio.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-08-18 01:56:10 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-08-18 01:56:10 -0400
commitcc62faa1c2c212d07c556e5368888ecc3ee537eb (patch)
tree8b0bc5b91cfd5a2d768586f887bdcabb3244ccca /MediaBrowser.Controller/Entities/Studio.cs
parentd6dc6ffe7e6f7a9699c764cba2bf32c996dcd771 (diff)
update season queries
Diffstat (limited to 'MediaBrowser.Controller/Entities/Studio.cs')
-rw-r--r--MediaBrowser.Controller/Entities/Studio.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs
index 7e3d6fe8e..04b09b744 100644
--- a/MediaBrowser.Controller/Entities/Studio.cs
+++ b/MediaBrowser.Controller/Entities/Studio.cs
@@ -85,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;
+ }
}
}