Update MediaBrowser.Controller/Playlists/Playlist.cs

Included suggested change from cvium

Co-authored-by: Claus Vium <cvium@users.noreply.github.com>
pull/5725/head
BrianCArnold 3 years ago committed by GitHub
parent 7c457da9ab
commit 2314487e38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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]

Loading…
Cancel
Save