diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-08-18 01:56:10 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-08-18 01:56:10 -0400 |
| commit | cc62faa1c2c212d07c556e5368888ecc3ee537eb (patch) | |
| tree | 8b0bc5b91cfd5a2d768586f887bdcabb3244ccca /MediaBrowser.Controller/Entities/Year.cs | |
| parent | d6dc6ffe7e6f7a9699c764cba2bf32c996dcd771 (diff) | |
update season queries
Diffstat (limited to 'MediaBrowser.Controller/Entities/Year.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/Year.cs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index db896f1fc..4197ea93e 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -112,5 +112,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.YearPath, 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; + } } } |
