diff options
| author | Brian Arnold <connect@brian-arnold.dev> | 2021-04-08 02:39:58 -0400 |
|---|---|---|
| committer | Brian Arnold <connect@brian-arnold.dev> | 2021-04-08 02:49:41 -0400 |
| commit | 7c457da9ab0803a467e8508203b527378066c099 (patch) | |
| tree | f6feeedc95e38e140f5b1eb8e5532bd25ec360de | |
| parent | 14f94b67934efd7af9efa0a09ffb83f86091d416 (diff) | |
Fixed issue with determining if a directory was a directory or file when it contained a '.' character in the directory path.
Resolves: #2845
| -rw-r--r-- | MediaBrowser.Controller/Playlists/Playlist.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index e8b7be7e2..faaceb828 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.IO; using System.Linq; using System.Text.Json.Serialization; using System.Threading; @@ -43,6 +44,16 @@ 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); } |
