-
Notifications
You must be signed in to change notification settings - Fork 787
Use filename timestamp for backup ordering and move to Utilities #3284
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
Use filename timestamp for backup ordering and move to Utilities #3284
Conversation
Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
|
@copilot move the method |
Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Done! Moved |
There was a problem hiding this 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 refactors the backup file ordering mechanism to use timestamps extracted directly from filenames instead of relying on file system creation times, ensuring consistent behavior across different file systems and after file operations.
- Extracts timestamps from backup filenames (
yyyyMMddHHmmssprefix) for reliable ordering - Adds three new utility methods to
TimestampHelperfor timestamp-based filename operations - Updates
CleanupBackupsto use filename-based timestamps with culture-invariant parsing
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| Source/NETworkManager.Utilities/TimestampHelper.cs | Adds three new public methods: GetTimestampFilename, IsTimestampedFilename, and ExtractTimestampFromFilename for generating, validating, and parsing timestamped filenames |
| Source/NETworkManager.Settings/SettingsManager.cs | Refactors backup creation calls to use GetTimestampFilename and updates CleanupBackups to filter and order backups using filename-based timestamps instead of file creation time |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
35e88cc
into
feature/daily_settings_backup
* Feature: Create a daily settings backup * Chore: Cleanup * Docs: #3283 * Chore: Cleanup * Fix: Fixes based on copilot feedback * Use filename timestamp for backup ordering and move to Utilities (#3284) * Initial plan * Extract date from filename for backup ordering Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> * Use InvariantCulture and specific exception handling Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> * Move ExtractTimestampFromFilename to TimestampHelper in Utilities Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> * Update comment to match specific exception handling Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> * Feature: Improve check * Update Source/NETworkManager.Utilities/TimestampHelper.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Source/NETworkManager.Utilities/TimestampHelper.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Source/NETworkManager.Utilities/TimestampHelper.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update TimestampHelper.cs * Update TimestampHelper.cs --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Feature: Some logging / docs --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Changes proposed in this pull request
yyyyMMddHHmmssprefix) for ordering instead of relying onFile.GetCreationTimeExtractTimestampFromFilenamemethod toTimestampHelper.csin Utilities project to parse filename timestamps withInvariantCulturefor consistent behaviorCleanupBackupsto use extracted timestamps, ensuring reliable ordering across file systems and copy operationsExtractTimestampFromFilenameas a public utility method inTimestampHelper.cs, making it reusable across the codebaseRelated issue(s)
Copilot generated summary
Copilot summary
File creation timestamps are unreliable across different file systems and after file operations like copying. Since backup filenames follow the format
yyyyMMddHHmmss_Settings.json(e.g.,20241225182301_Settings.json), we now extract and parse this embedded timestamp for ordering. Invalid filenames returnDateTime.MinValueto sort as oldest.Changes:
ExtractTimestampFromFilenamehelper method toTimestampHelper.csin Utilities with proper culture-invariant parsingCleanupBackupsordering fromFile.GetCreationTime(f)toTimestampHelper.ExtractTimestampFromFilename(f)To-Do
Contributing
By submitting this pull request, I confirm the following:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.