Skip to content
Draft
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 Source/NETworkManager.Profiles/ProfileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ private static void CreateDailyBackupIfNeeded()
// Create backup
Backup(LoadedProfileFile.Path,
GetProfilesBackupFolderLocation(),
TimestampHelper.GetTimestampFilename(profileFileName));
TimestampHelper.GetTimestampFilename(profileFileName, AssemblyManager.Current.Version.ToString()));

// Cleanup old backups
CleanupBackups(GetProfilesBackupFolderLocation(),
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager.Settings/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ private static void CreateDailyBackupIfNeeded()
// Create backup
Backup(GetSettingsFilePath(),
GetSettingsBackupFolderLocation(),
TimestampHelper.GetTimestampFilename(GetSettingsFileName()));
TimestampHelper.GetTimestampFilename(GetSettingsFileName(), AssemblyManager.Current.Version.ToString()));

// Cleanup old backups
CleanupBackups(GetSettingsBackupFolderLocation(),
Expand Down
19 changes: 15 additions & 4 deletions Source/NETworkManager.Utilities/TimestampHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,24 @@ public static string GetTimestamp()
}

/// <summary>
/// Generates a filename by prefixing the specified filename with a timestamp string.
/// Generates a filename by prefixing the specified filename with a timestamp string and an optional version string.
/// </summary>
/// <param name="fileName">The original filename to be prefixed with a timestamp. Cannot be null or empty.</param>
/// <returns>A string containing the timestamp followed by an underscore and the original filename.</returns>
public static string GetTimestampFilename(string fileName)
/// <param name="version">
/// An optional version string to include between the timestamp and the filename. If provided, dots in the
/// version are replaced with dashes (e.g., "2026.3.4.0" becomes "2026-3-4-0").
/// </param>
/// <returns>
/// A string in the format <c>&lt;timestamp&gt;_&lt;version&gt;_&lt;fileName&gt;</c> when a version is
/// provided, or <c>&lt;timestamp&gt;_&lt;fileName&gt;</c> otherwise.
/// </returns>
public static string GetTimestampFilename(string fileName, string version = null)
{
return $"{GetTimestamp()}_{fileName}";
var versionSegment = string.IsNullOrWhiteSpace(version)
? string.Empty
: $"_{version.Replace('.', '-')}";

return $"{GetTimestamp()}{versionSegment}_{fileName}";
}

/// <summary>
Expand Down