mirror of
https://github.com/Lidarr/Lidarr
synced 2025-12-06 08:25:54 +01:00
New: Migrate appdata folder for .NET 8 on OSX
(cherry picked from commit d62547236a5e506ca9b11bf369683691ed8d253b)
This commit is contained in:
parent
96328b8d95
commit
1a4c1b6db5
2 changed files with 27 additions and 2 deletions
|
|
@ -18,6 +18,7 @@ public class AppFolderFactory : IAppFolderFactory
|
|||
{
|
||||
private readonly IAppFolderInfo _appFolderInfo;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IDiskTransferService _diskTransferService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public AppFolderFactory(IAppFolderInfo appFolderInfo,
|
||||
|
|
@ -27,6 +28,7 @@ public AppFolderFactory(IAppFolderInfo appFolderInfo,
|
|||
{
|
||||
_appFolderInfo = appFolderInfo;
|
||||
_diskProvider = diskProvider;
|
||||
_diskTransferService = diskTransferService;
|
||||
_logger = NzbDroneLogger.GetLogger(this);
|
||||
}
|
||||
|
||||
|
|
@ -34,6 +36,7 @@ public void Register()
|
|||
{
|
||||
try
|
||||
{
|
||||
MigrateAppDataFolder();
|
||||
_diskProvider.EnsureFolder(_appFolderInfo.AppDataFolder);
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
|
|
@ -66,6 +69,28 @@ public void SetPermissions()
|
|||
}
|
||||
}
|
||||
|
||||
private void MigrateAppDataFolder()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (OsInfo.IsOsx)
|
||||
{
|
||||
var userAppDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile, Environment.SpecialFolderOption.DoNotVerify), ".config", "Lidarr");
|
||||
|
||||
if (_diskProvider.FolderExists(userAppDataFolder) && !_diskProvider.FileExists(_appFolderInfo.GetConfigPath()))
|
||||
{
|
||||
_diskTransferService.MirrorFolder(userAppDataFolder, _appFolderInfo.AppDataFolder);
|
||||
_diskProvider.DeleteFolder(userAppDataFolder, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Debug(ex, ex.Message);
|
||||
throw new LidarrStartupException(ex, "Unable to migrate configuration folder to {0}. Migrate manually", _appFolderInfo.AppDataFolder);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeMonoApplicationData()
|
||||
{
|
||||
if (OsInfo.IsWindows)
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ public AppFolderInfo(IStartupContext startupContext)
|
|||
_dataSpecialFolder = Environment.SpecialFolder.ApplicationData;
|
||||
}
|
||||
|
||||
if (startupContext.Args.ContainsKey(StartupContext.APPDATA))
|
||||
if (startupContext.Args.TryGetValue(StartupContext.APPDATA, out var argsAppDataFolder))
|
||||
{
|
||||
AppDataFolder = startupContext.Args[StartupContext.APPDATA];
|
||||
AppDataFolder = argsAppDataFolder;
|
||||
Logger.Info("Data directory is being overridden to [{0}]", AppDataFolder);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in a new issue