encapsulate path substitution
This commit is contained in:
parent
e7124e1ec5
commit
151d88f20d
|
@ -2111,10 +2111,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
if (locationType == LocationType.FileSystem || locationType == LocationType.Offline)
|
if (locationType == LocationType.FileSystem || locationType == LocationType.Offline)
|
||||||
{
|
{
|
||||||
foreach (var map in ConfigurationManager.Configuration.PathSubstitutions)
|
return LibraryManager.GetPathAfterNetworkSubstitution(path);
|
||||||
{
|
|
||||||
path = LibraryManager.SubstitutePath(path, map.From, map.To);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
|
|
@ -506,6 +506,8 @@ namespace MediaBrowser.Controller.Library
|
||||||
/// <returns>QueryResult<BaseItem>.</returns>
|
/// <returns>QueryResult<BaseItem>.</returns>
|
||||||
QueryResult<BaseItem> QueryItems(InternalItemsQuery query);
|
QueryResult<BaseItem> QueryItems(InternalItemsQuery query);
|
||||||
|
|
||||||
|
string GetPathAfterNetworkSubstitution(string path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Substitutes the path.
|
/// Substitutes the path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -343,7 +343,8 @@ namespace MediaBrowser.Dlna.Main
|
||||||
if (_Publisher != null)
|
if (_Publisher != null)
|
||||||
{
|
{
|
||||||
var devices = _Publisher.Devices.ToList();
|
var devices = _Publisher.Devices.ToList();
|
||||||
foreach (var device in devices)
|
|
||||||
|
Parallel.ForEach(devices, device =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -353,7 +354,18 @@ namespace MediaBrowser.Dlna.Main
|
||||||
{
|
{
|
||||||
_logger.ErrorException("Error sending bye bye", ex);
|
_logger.ErrorException("Error sending bye bye", ex);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
//foreach (var device in devices)
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// _Publisher.RemoveDevice(device);
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// _logger.ErrorException("Error sending bye bye", ex);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
_Publisher.Dispose();
|
_Publisher.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1516,10 +1516,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
|
|
||||||
if (locationType == LocationType.FileSystem || locationType == LocationType.Offline)
|
if (locationType == LocationType.FileSystem || locationType == LocationType.Offline)
|
||||||
{
|
{
|
||||||
foreach (var map in _config.Configuration.PathSubstitutions)
|
path = _libraryManager.GetPathAfterNetworkSubstitution(path);
|
||||||
{
|
|
||||||
path = _libraryManager.SubstitutePath(path, map.From, map.To);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
|
|
@ -2527,6 +2527,16 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
}).OrderBy(i => i.Path).ToList();
|
}).OrderBy(i => i.Path).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetPathAfterNetworkSubstitution(string path)
|
||||||
|
{
|
||||||
|
foreach (var map in ConfigurationManager.Configuration.PathSubstitutions)
|
||||||
|
{
|
||||||
|
path = SubstitutePath(path, map.From, map.To);
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
public string SubstitutePath(string path, string from, string to)
|
public string SubstitutePath(string path, string from, string to)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(path))
|
if (string.IsNullOrWhiteSpace(path))
|
||||||
|
|
|
@ -15,6 +15,7 @@ using System.Linq;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.ServiceProcess;
|
using System.ServiceProcess;
|
||||||
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
@ -37,9 +38,31 @@ namespace MediaBrowser.ServerApplication
|
||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
static extern bool SetDllDirectory(string lpPathName);
|
static extern bool SetDllDirectory(string lpPathName);
|
||||||
|
|
||||||
|
public static bool TryGetLocalFromUncDirectory(string local, out string unc)
|
||||||
|
{
|
||||||
|
if ((local == null) || (local == ""))
|
||||||
|
{
|
||||||
|
unc = "";
|
||||||
|
throw new ArgumentNullException("local");
|
||||||
|
}
|
||||||
|
|
||||||
|
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Name FROM Win32_share WHERE path ='" + local.Replace("\\", "\\\\") + "'");
|
||||||
|
ManagementObjectCollection coll = searcher.Get();
|
||||||
|
if (coll.Count == 1)
|
||||||
|
{
|
||||||
|
foreach (ManagementObject share in searcher.Get())
|
||||||
|
{
|
||||||
|
unc = share["Name"] as String;
|
||||||
|
unc = "\\\\" + SystemInformation.ComputerName + "\\" + unc;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unc = "";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the entry point of the application.
|
/// Defines the entry point of the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
var options = new StartupOptions();
|
var options = new StartupOptions();
|
||||||
|
|
|
@ -1040,12 +1040,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
||||||
|
|
||||||
private static string GetPathToSave(string path, ILibraryManager libraryManager, IServerConfigurationManager config)
|
private static string GetPathToSave(string path, ILibraryManager libraryManager, IServerConfigurationManager config)
|
||||||
{
|
{
|
||||||
foreach (var map in config.Configuration.PathSubstitutions)
|
return libraryManager.GetPathAfterNetworkSubstitution(path);
|
||||||
{
|
|
||||||
path = libraryManager.SubstitutePath(path, map.From, map.To);
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsPersonType(PersonInfo person, string type)
|
private static bool IsPersonType(PersonInfo person, string type)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user