2016-09-08 23:05:27 +00:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using NLog;
|
2022-03-02 15:28:32 +00:00
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
using NzbDrone.Common.Extensions;
|
2016-09-08 23:05:27 +00:00
|
|
|
|
|
|
|
namespace NzbDrone.Update.UpdateEngine
|
|
|
|
{
|
|
|
|
public interface IDetectExistingVersion
|
|
|
|
{
|
|
|
|
string GetExistingVersion(string targetFolder);
|
|
|
|
}
|
|
|
|
|
|
|
|
public class DetectExistingVersion : IDetectExistingVersion
|
|
|
|
{
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
public DetectExistingVersion(Logger logger)
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string GetExistingVersion(string targetFolder)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2022-03-06 13:20:06 +00:00
|
|
|
var targetExecutable = Path.Combine(targetFolder, "Radarr.dll");
|
2016-09-08 23:05:27 +00:00
|
|
|
|
|
|
|
if (File.Exists(targetExecutable))
|
|
|
|
{
|
|
|
|
var versionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(targetExecutable);
|
|
|
|
|
2022-03-06 13:20:06 +00:00
|
|
|
return versionInfo.ProductVersion;
|
2016-09-08 23:05:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
_logger.Warn(ex, "Failed to get existing version from {0}", targetFolder);
|
|
|
|
}
|
|
|
|
|
|
|
|
return "(unknown)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|