mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-11 20:56:32 +00:00
added dlna music folders
This commit is contained in:
@@ -88,7 +88,7 @@ namespace MediaBrowser.Common.Implementations.Configuration
|
||||
}
|
||||
|
||||
private ConfigurationStore[] _configurationStores = {};
|
||||
private IConfigurationFactory[] _configurationFactories;
|
||||
private IConfigurationFactory[] _configurationFactories = {};
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseConfigurationManager" /> class.
|
||||
|
||||
99
MediaBrowser.Common.Implementations/Devices/DeviceId.cs
Normal file
99
MediaBrowser.Common.Implementations/Devices/DeviceId.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace MediaBrowser.Common.Implementations.Devices
|
||||
{
|
||||
public class DeviceId
|
||||
{
|
||||
private readonly IApplicationPaths _appPaths;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly object _syncLock = new object();
|
||||
|
||||
private string CachePath
|
||||
{
|
||||
get { return Path.Combine(_appPaths.DataPath, "device.txt"); }
|
||||
}
|
||||
|
||||
private string GetCachedId()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_syncLock)
|
||||
{
|
||||
var value = File.ReadAllText(CachePath, Encoding.UTF8);
|
||||
|
||||
Guid guid;
|
||||
if (Guid.TryParse(value, out guid))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
_logger.Error("Invalid value found in device id file");
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error reading file", ex);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void SaveId(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var path = CachePath;
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
lock (_syncLock)
|
||||
{
|
||||
File.WriteAllText(path, id, Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error writing to file", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetNewId()
|
||||
{
|
||||
return Guid.NewGuid().ToString("N");
|
||||
}
|
||||
|
||||
private string GetDeviceId()
|
||||
{
|
||||
var id = GetCachedId();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(id))
|
||||
{
|
||||
id = GetNewId();
|
||||
SaveId(id);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
private string _id;
|
||||
|
||||
public DeviceId(IApplicationPaths appPaths, ILogger logger)
|
||||
{
|
||||
_appPaths = appPaths;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public string Value
|
||||
{
|
||||
get { return _id ?? (_id = GetDeviceId()); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,7 @@
|
||||
<Compile Include="BaseApplicationHost.cs" />
|
||||
<Compile Include="BaseApplicationPaths.cs" />
|
||||
<Compile Include="Configuration\BaseConfigurationManager.cs" />
|
||||
<Compile Include="Devices\DeviceId.cs" />
|
||||
<Compile Include="HttpClientManager\HttpClientInfo.cs" />
|
||||
<Compile Include="HttpClientManager\HttpClientManager.cs" />
|
||||
<Compile Include="IO\CommonFileSystem.cs" />
|
||||
|
||||
Reference in New Issue
Block a user