Skip to content

Conversation

@tvatavuk
Copy link

Fixed #17

Copilot AI review requested due to automatic review settings December 12, 2025 16:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a DateTimeOffset exception that occurs when HostFileChangeMonitor is initialized with a non-existent koi.json file in DNN skins. The fix adds proper file existence checks and fallback cache expiration strategies.

Key Changes:

  • Added file existence check before attempting to monitor the koi.json file for changes
  • Implemented time-based cache expiration (5 minutes) as a fallback when the file doesn't exist or monitoring fails
  • Improved cache key generation by using ToLowerInvariant() instead of ToLower()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +62 to +68
policy.AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5);
}
}
else
{
// Re-check occasionally in case koi.json gets created later.
policy.AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5);
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache expiration time of 5 minutes is duplicated on lines 62 and 68. Consider extracting this magic number to a private constant (e.g., CacheFallbackExpirationMinutes) to improve maintainability and make it easier to adjust this value consistently in the future.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

@iJungleboy
Copy link
Collaborator

ATM I'm not sure if this is something we want to support, as it doesn't really fix anything.
The correct solution is to get the koi.json and restart.

This method doesn't need the restart, but it will "randomly start working" after the specified time, so I feel like it's not doing much, and could confuse people even further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connect.Koi auto-detect throws DateTimeOffset exception when no koi.json exists in default DNN skin

2 participants