From 1a44d53fefa3c2f3e542abfccb333598eafb8f01 Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 29 Jun 2021 22:58:12 -0400 Subject: [PATCH] New: mono disk and process provider cleaning --- .../Processes/ProcessProvider.cs | 11 +------ src/NzbDrone.Mono/Disk/DiskProvider.cs | 31 ++----------------- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/src/NzbDrone.Common/Processes/ProcessProvider.cs b/src/NzbDrone.Common/Processes/ProcessProvider.cs index c616fd75d..9336248bc 100644 --- a/src/NzbDrone.Common/Processes/ProcessProvider.cs +++ b/src/NzbDrone.Common/Processes/ProcessProvider.cs @@ -336,16 +336,7 @@ namespace NzbDrone.Common.Processes private List GetProcessesByName(string name) { - //TODO: move this to an OS specific class - var monoProcesses = Process.GetProcessesByName("mono") - .Union(Process.GetProcessesByName("mono-sgen")) - .Where(process => - process.Modules.Cast() - .Any(module => - module.ModuleName.ToLower() == name.ToLower() + ".exe")); - - var processes = Process.GetProcessesByName(name) - .Union(monoProcesses).ToList(); + var processes = Process.GetProcessesByName(name).ToList(); _logger.Debug("Found {0} processes with the name: {1}", processes.Count, name); diff --git a/src/NzbDrone.Mono/Disk/DiskProvider.cs b/src/NzbDrone.Mono/Disk/DiskProvider.cs index 144c2be2f..e8875ea09 100644 --- a/src/NzbDrone.Mono/Disk/DiskProvider.cs +++ b/src/NzbDrone.Mono/Disk/DiskProvider.cs @@ -329,9 +329,7 @@ namespace NzbDrone.Mono.Disk // Catch the exception and attempt to handle these edgecases // Mono 6.x till 6.10 doesn't properly try use rename first. - if (move && - ((PlatformInfo.Platform == PlatformType.Mono && PlatformInfo.GetVersion() < new Version(6, 10)) || - (PlatformInfo.Platform == PlatformType.NetCore))) + if (move && (PlatformInfo.Platform == PlatformType.NetCore)) { if (Syscall.lstat(source, out var sourcestat) == 0 && Syscall.lstat(destination, out var deststat) != 0 && @@ -359,32 +357,7 @@ namespace NzbDrone.Mono.Disk var dstInfo = new FileInfo(destination); var exists = dstInfo.Exists && srcInfo.Exists; - if (PlatformInfo.Platform == PlatformType.Mono && PlatformInfo.GetVersion() >= new Version(6, 6) && - exists && dstInfo.Length == 0 && srcInfo.Length != 0) - { - // mono >=6.6 bug: zero length file since chmod happens at the start - _logger.Debug("{3} failed to {2} file likely due to known {3} bug, attempting to {2} directly. '{0}' -> '{1}'", source, destination, move ? "move" : "copy", PlatformInfo.PlatformName); - - try - { - _logger.Trace("Copying content from {0} to {1} ({2} bytes)", source, destination, srcInfo.Length); - using (var srcStream = new FileStream(source, FileMode.Open, FileAccess.Read)) - using (var dstStream = new FileStream(destination, FileMode.Create, FileAccess.Write)) - { - srcStream.CopyTo(dstStream); - } - } - catch - { - // If it fails again then bail - throw; - } - } - else if (((PlatformInfo.Platform == PlatformType.Mono && - PlatformInfo.GetVersion() >= new Version(6, 0) && - PlatformInfo.GetVersion() < new Version(6, 6)) || - PlatformInfo.Platform == PlatformType.NetCore) && - exists && dstInfo.Length == srcInfo.Length) + if (PlatformInfo.Platform == PlatformType.NetCore && exists && dstInfo.Length == srcInfo.Length) { // mono 6.0, mono 6.4 and netcore 3.1 bug: full length file since utime and chmod happens at the end _logger.Debug("{3} failed to {2} file likely due to known {3} bug, attempting to {2} directly. '{0}' -> '{1}'", source, destination, move ? "move" : "copy", PlatformInfo.PlatformName);