Fixed issue with determining if a directory was a directory or file when it contained a '.' character in the directory path.
Resolves: #2845
This commit is contained in:
parent
14f94b6793
commit
7c457da9ab
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user