mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Add an import date property to mod metas
This commit is contained in:
parent
fdc84836c9
commit
4d6d73abb6
1 changed files with 11 additions and 1 deletions
|
|
@ -9,7 +9,7 @@ using OtterGui.Classes;
|
||||||
namespace Penumbra.Mods;
|
namespace Penumbra.Mods;
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum MetaChangeType : byte
|
public enum MetaChangeType : ushort
|
||||||
{
|
{
|
||||||
None = 0x00,
|
None = 0x00,
|
||||||
Name = 0x01,
|
Name = 0x01,
|
||||||
|
|
@ -19,6 +19,7 @@ public enum MetaChangeType : byte
|
||||||
Website = 0x10,
|
Website = 0x10,
|
||||||
Deletion = 0x20,
|
Deletion = 0x20,
|
||||||
Migration = 0x40,
|
Migration = 0x40,
|
||||||
|
ImportDate = 0x80,
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed partial class Mod
|
public sealed partial class Mod
|
||||||
|
|
@ -30,6 +31,7 @@ public sealed partial class Mod
|
||||||
public string Description { get; private set; } = string.Empty;
|
public string Description { get; private set; } = string.Empty;
|
||||||
public string Version { get; private set; } = string.Empty;
|
public string Version { get; private set; } = string.Empty;
|
||||||
public string Website { get; private set; } = string.Empty;
|
public string Website { get; private set; } = string.Empty;
|
||||||
|
public long ImportDate { get; private set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||||
|
|
||||||
internal FileInfo MetaFile
|
internal FileInfo MetaFile
|
||||||
=> new(Path.Combine( BasePath.FullName, "meta.json" ));
|
=> new(Path.Combine( BasePath.FullName, "meta.json" ));
|
||||||
|
|
@ -54,6 +56,7 @@ public sealed partial class Mod
|
||||||
var newVersion = json[ nameof( Version ) ]?.Value< string >() ?? string.Empty;
|
var newVersion = json[ nameof( Version ) ]?.Value< string >() ?? string.Empty;
|
||||||
var newWebsite = json[ nameof( Website ) ]?.Value< string >() ?? string.Empty;
|
var newWebsite = json[ nameof( Website ) ]?.Value< string >() ?? string.Empty;
|
||||||
var newFileVersion = json[ nameof( FileVersion ) ]?.Value< uint >() ?? 0;
|
var newFileVersion = json[ nameof( FileVersion ) ]?.Value< uint >() ?? 0;
|
||||||
|
var importDate = json[ nameof( ImportDate ) ]?.Value< long >() ?? DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||||
|
|
||||||
MetaChangeType changes = 0;
|
MetaChangeType changes = 0;
|
||||||
if( Name != newName )
|
if( Name != newName )
|
||||||
|
|
@ -95,6 +98,12 @@ public sealed partial class Mod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( ImportDate != importDate )
|
||||||
|
{
|
||||||
|
ImportDate = importDate;
|
||||||
|
changes |= MetaChangeType.ImportDate;
|
||||||
|
}
|
||||||
|
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -117,6 +126,7 @@ public sealed partial class Mod
|
||||||
{ nameof( Description ), JToken.FromObject( Description ) },
|
{ nameof( Description ), JToken.FromObject( Description ) },
|
||||||
{ nameof( Version ), JToken.FromObject( Version ) },
|
{ nameof( Version ), JToken.FromObject( Version ) },
|
||||||
{ nameof( Website ), JToken.FromObject( Website ) },
|
{ nameof( Website ), JToken.FromObject( Website ) },
|
||||||
|
{ nameof( ImportDate ), JToken.FromObject( ImportDate ) },
|
||||||
};
|
};
|
||||||
File.WriteAllText( metaFile.FullName, jObject.ToString( Formatting.Indented ) );
|
File.WriteAllText( metaFile.FullName, jObject.ToString( Formatting.Indented ) );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue