diff options
| author | BrianCArnold <trenchie@trenchie.us> | 2021-04-08 04:03:43 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-08 04:03:43 -0400 |
| commit | 2314487e38d77f5d3a123ad2f0e76ab6ea2134c7 (patch) | |
| tree | a66aaa39adc0ea09863684cad4b853180164dbb7 | |
| parent | 7c457da9ab0803a467e8508203b527378066c099 (diff) | |
Update MediaBrowser.Controller/Playlists/Playlist.cs
Included suggested change from cvium
Co-authored-by: Claus Vium <cvium@users.noreply.github.com>
| -rw-r--r-- | MediaBrowser.Controller/Playlists/Playlist.cs | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index faaceb828..089d241ba 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -44,17 +44,8 @@ namespace MediaBrowser.Controller.Playlists public static bool IsPlaylistFile(string path) { - //When a directory contains a `.`, calling "HasExtension" will return true, even if that location is a directory that exists. - //This kills the PlaylistXmlSaver, because instead of saving in "config/data/playlists/MyList2.0/playlist.xml", - //It saves the information in "config/data/playlists/MyList2.xml". So we just need to see if it's actually a real directory first. - //Lucky for us, when a new playlist is created, the directory on the drive is created first, then the Playlist object is created. - //And if there's not a directory there, then we can just check if it has an extension. - if (new System.IO.DirectoryInfo(path).Exists) - { //This is a directory, and therefore definitely not a playlist file. - return false; - } - //Well, there's no directory there, so if it /looks/ like a file path, then it probably is. - return System.IO.Path.HasExtension(path); + // The path will sometimes be a directory and "Path.HasExtension" returns true if the name contains a '.' (dot). + return Path.HasExtension(path) && !Directory.Exists(path); } [JsonIgnore] |
