mirror of
https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies.git
synced 2026-08-02 17:51:38 +00:00
5242b0009b
- Fix crash: Updated SaveMafileAsync to properly update or add to MaFiles collection - Fix naming logic: Added Filename reset logic to adding new mafile to prevent inconsistent and duplicating import - Extracted mafile path and naming logic to MafilesStorageHelper for better modularity - Refactored Storage methods to use MafilesStorageHelper - Replaced all sync mafile save/add calls with async/await versions throughout the codebase - Performed code cleanups and improved maintainability for mafile-related operations
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using System.IO;
|
|
using NebulaAuth.Model.Entities;
|
|
|
|
namespace NebulaAuth.Model.Mafiles;
|
|
|
|
internal static class MafilesStorageHelper
|
|
{
|
|
/// <summary>
|
|
/// Returns <see cref="Mafile.Filename" /> or creates a new one and updates the property.
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <returns></returns>
|
|
public static string GetOrUpdateMafilePath(Mafile data)
|
|
{
|
|
if (data.Filename != null)
|
|
{
|
|
return Path.Combine(Storage.MafilesDirectory, data.Filename);
|
|
}
|
|
|
|
var fileName = CreateMafileFileName(data, Settings.Instance.UseAccountNameAsMafileName);
|
|
data.Filename = fileName;
|
|
return Path.Combine(Storage.MafilesDirectory, fileName);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates mafile file name according to the current settings.
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <param name="useAccountName"></param>
|
|
/// <returns></returns>
|
|
public static string CreateMafileFileName(Mafile data, bool useAccountName)
|
|
{
|
|
return useAccountName
|
|
? MafileNamingStrategy.Login.GetMafileName(data)
|
|
: MafileNamingStrategy.SteamId.GetMafileName(data);
|
|
}
|
|
} |