From 465de11c9092b704469db6fa03d907da4c540204 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 11 Oct 2020 19:26:33 +0200 Subject: [PATCH] Fixed: Regression causing updater to fail (manual update required if on 3.0.3.971, see forums) --- .../DiskTests/DiskTransferServiceFixture.cs | 17 +++++++++++++++++ src/NzbDrone.Common/Disk/DiskTransferService.cs | 9 ++++++--- .../UpdateEngine/InstallUpdateService.cs | 6 ++++++ version.sh | 2 +- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs b/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs index 16848b3b7..da1e5fb5f 100644 --- a/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs +++ b/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs @@ -661,6 +661,23 @@ namespace NzbDrone.Common.Test.DiskTests VerifyCopyFolder(original.FullName, destination.FullName); } + [Test] + public void MirrorFolder_should_handle_trailing_slash() + { + WithRealDiskProvider(); + + var original = GetFilledTempFolder(); + var source = new DirectoryInfo(GetTempFilePath()); + var destination = new DirectoryInfo(GetTempFilePath()); + + Subject.TransferFolder(original.FullName, source.FullName, TransferMode.Copy); + + var count = Subject.MirrorFolder(source.FullName + Path.DirectorySeparatorChar, destination.FullName); + + count.Should().Equals(3); + VerifyCopyFolder(original.FullName, destination.FullName); + } + [Test] public void TransferFolder_should_use_movefolder_if_on_same_mount() { diff --git a/src/NzbDrone.Common/Disk/DiskTransferService.cs b/src/NzbDrone.Common/Disk/DiskTransferService.cs index 4ad4b6b56..42e672e8a 100644 --- a/src/NzbDrone.Common/Disk/DiskTransferService.cs +++ b/src/NzbDrone.Common/Disk/DiskTransferService.cs @@ -29,13 +29,16 @@ namespace NzbDrone.Common.Disk private string ResolveRealParentPath(string path) { var parentPath = path.GetParentPath(); - if (!_diskProvider.FolderExists(path)) + if (!_diskProvider.FolderExists(parentPath)) { return path; } - parentPath = parentPath.GetActualCasing(); - return parentPath + Path.DirectorySeparatorChar + Path.GetFileName(path); + var realParentPath = parentPath.GetActualCasing(); + + var partialChildPath = path.Substring(parentPath.Length); + + return realParentPath + partialChildPath; } public TransferMode TransferFolder(string sourcePath, string targetPath, TransferMode mode) diff --git a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs index 508556e80..eb82a5f16 100644 --- a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs +++ b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs @@ -84,6 +84,12 @@ namespace NzbDrone.Update.UpdateEngine Verify(installationFolder, processId); + if (installationFolder.EndsWith(@"\bin\Sonarr") || installationFolder.EndsWith(@"/bin/Sonarr")) + { + installationFolder = installationFolder.GetParentPath(); + _logger.Info("Fixed Installation Folder: {0}", installationFolder); + } + var appType = _detectApplicationType.GetAppType(); _processProvider.FindProcessByName(ProcessProvider.SONARR_CONSOLE_PROCESS_NAME); diff --git a/version.sh b/version.sh index d1c1fb591..962dd2550 100644 --- a/version.sh +++ b/version.sh @@ -1,7 +1,7 @@ #! /bin/bash # Increment packageVersion when package scripts change -packageVersion='3.0.3' +packageVersion='3.0.4' # For now we keep the build version and package version the same buildVersion=$packageVersion