From 470861111e0397c647fee65b07de77c79ace17e1 Mon Sep 17 00:00:00 2001 From: Chomp Date: Mon, 16 Jun 2025 21:23:34 +0100 Subject: [PATCH] Updated `ExtractDateFromFolderName` to make use of PATH class --- .../Services/BackupService.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Services/BackupService.cs b/Libraries/SPTarkov.Server.Core/Services/BackupService.cs index c4feb7d1..757a926f 100644 --- a/Libraries/SPTarkov.Server.Core/Services/BackupService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/BackupService.cs @@ -258,24 +258,25 @@ public class BackupService /// /// Extracts a date from a folder name string formatted as `YYYY-MM-DD_hh-mm-ss`. /// - /// The name of the folder from which to extract the date. + /// The name of the folder from which to extract the date. /// A DateTime object if the folder name is in the correct format, otherwise null. - private DateTime? ExtractDateFromFolderName(string folderName) + private DateTime? ExtractDateFromFolderName(string folderPath) { // backup - var parts = folderName.Split('\\', '-', '_'); - if (parts.Length != 7) + var folderName = Path.GetFileName(folderPath); + var parts = folderName.Split('-', '_'); + if (parts.Length != 6) { - _logger.Warning($"Invalid backup folder name format: {folderName}"); + _logger.Warning($"Invalid backup folder name format: {folderPath}"); return null; } - var year = int.Parse(parts[1]); - var month = int.Parse(parts[2]); - var day = int.Parse(parts[3]); - var hour = int.Parse(parts[4]); - var minute = int.Parse(parts[5]); - var second = int.Parse(parts[6]); + var year = int.Parse(parts[0]); + var month = int.Parse(parts[1]); + var day = int.Parse(parts[2]); + var hour = int.Parse(parts[3]); + var minute = int.Parse(parts[4]); + var second = int.Parse(parts[5]); return new DateTime(year, month, day, hour, minute, second); }