Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cache timestamp comparisons #3974

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Net/NetFileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private string scanDirectory(Dictionary<string, string> files, string findHash,
// Check local vs remote timestamps; if local is older, then it's invalid.
// null means we don't know the remote timestamp (so file is OK)
if (remoteTimestamp == null
|| remoteTimestamp < File.GetLastWriteTime(file).ToUniversalTime())
|| remoteTimestamp < File.GetLastWriteTimeUtc(file))
{
// File not too old, use it
log.Debug("Found good file, using it");
Expand Down
6 changes: 5 additions & 1 deletion Core/Registry/Registry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,11 @@ public void Rollback(Enlistment enlistment)
// we had previously.

lock (txMutex) {
var options = new JsonSerializerSettings {ObjectCreationHandling = ObjectCreationHandling.Replace};
var options = new JsonSerializerSettings
{
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
ObjectCreationHandling = ObjectCreationHandling.Replace
};

JsonConvert.PopulateObject(transaction_backup, this, options);

Expand Down
1 change: 1 addition & 0 deletions Core/Registry/RegistryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ private void Load(RepositoryDataManager repoData)
// after deserialisation.
var settings = new JsonSerializerSettings
{
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
Context = new StreamingContext(StreamingContextStates.Other, gameInstance)
};

Expand Down
1 change: 1 addition & 0 deletions Core/Repositories/RepositoryData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public static RepositoryData FromJson(string path, IProgress<int> progress)
{
var settings = new JsonSerializerSettings()
{
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
Context = new StreamingContext(
StreamingContextStates.Other,
progress == null
Expand Down
5 changes: 4 additions & 1 deletion Core/Types/CkanModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@ public CkanModule(string json, IGameComparator comparator)
try
{
// Use the json string to populate our object
JsonConvert.PopulateObject(json, this);
JsonConvert.PopulateObject(json, this, new JsonSerializerSettings
{
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
});
}
catch (JsonException ex)
{
Expand Down
1 change: 1 addition & 0 deletions Netkan/Services/ModuleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ public static AvcVersion GetInternalAvc(ZipFile zipfile, ZipEntry avcEntry)
private const string SpaceWarpInfoFilename = "swinfo.json";
private static readonly JsonSerializerSettings ignoreJsonErrors = new JsonSerializerSettings()
{
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
Error = (sender, e) => e.ErrorContext.Handled = true
};

Expand Down
Loading