mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Store the date a build is created
This commit is contained in:
@@ -211,4 +211,11 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Save the compiled date so that we know if the user is running an old version of Jackett -->
|
||||||
|
<ItemGroup>
|
||||||
|
<AssemblyAttribute Include="Jackett.Common.Utils.BuildDateAttribute">
|
||||||
|
<_Parameter1>$([System.DateTime]::UtcNow.ToString("yyyyMMddHHmmss"))</_Parameter1>
|
||||||
|
</AssemblyAttribute>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
27
src/Jackett.Common/Utils/BuildDate.cs
Normal file
27
src/Jackett.Common/Utils/BuildDate.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Jackett.Common.Utils
|
||||||
|
{
|
||||||
|
public static class BuildDate
|
||||||
|
{
|
||||||
|
public static DateTime GetBuildDateTime()
|
||||||
|
{
|
||||||
|
Assembly commonAssembly = Assembly.GetExecutingAssembly();
|
||||||
|
var attribute = commonAssembly.GetCustomAttribute<BuildDateAttribute>();
|
||||||
|
return attribute?.DateTime ?? default(DateTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Assembly)]
|
||||||
|
public class BuildDateAttribute : Attribute
|
||||||
|
{
|
||||||
|
public BuildDateAttribute(string value)
|
||||||
|
{
|
||||||
|
DateTime = DateTime.ParseExact(value, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime DateTime { get; }
|
||||||
|
}
|
||||||
|
}
|
@@ -261,14 +261,9 @@ namespace Jackett.Server.Services
|
|||||||
//Warn user that they are using an old version of Jackett
|
//Warn user that they are using an old version of Jackett
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string appFolder = configService.ApplicationFolder();
|
DateTime compiledData = BuildDate.GetBuildDateTime();
|
||||||
string dllPath = Path.Combine(appFolder, "Jackett.Common.dll");
|
|
||||||
|
|
||||||
if (File.Exists(dllPath))
|
if (compiledData < DateTime.Now.AddMonths(-3))
|
||||||
{
|
|
||||||
DateTime creation = File.GetCreationTime(dllPath);
|
|
||||||
|
|
||||||
if (creation < DateTime.Now.AddMonths(-3))
|
|
||||||
{
|
{
|
||||||
string version = configService.GetVersion();
|
string version = configService.GetVersion();
|
||||||
string notice = $"Your version of Jackett v{version} is very old. Multiple indexers are likely to fail when using an old version. Update to the latest version of Jackett.";
|
string notice = $"Your version of Jackett v{version} is very old. Multiple indexers are likely to fail when using an old version. Update to the latest version of Jackett.";
|
||||||
@@ -276,7 +271,6 @@ namespace Jackett.Server.Services
|
|||||||
logger.Error(notice);
|
logger.Error(notice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.Error(e, "Error while checking build date of Jackett.Common");
|
logger.Error(e, "Error while checking build date of Jackett.Common");
|
||||||
|
Reference in New Issue
Block a user