Fixed parameters to ensure no null values are passed incorrectly

This commit is contained in:
Casper Sparre 2025-10-14 00:35:31 +02:00
parent 0987c7498b
commit c8e8eaa737
3 changed files with 5 additions and 5 deletions

View File

@ -254,9 +254,9 @@ namespace OF_DL.Helpers
return result;
}
public async Task UpdateUserInfo(User? user)
public async Task UpdateUserInfo(string username, User? user)
{
if (user is null)
if (user?.id is null)
return;
SqliteConnection connection = await GetAndOpenConnectionAsync($"Data Source={Directory.GetCurrentDirectory()}/users.db");
@ -270,7 +270,7 @@ namespace OF_DL.Helpers
);
cmdInfo.Parameters.AddWithValue("@userId", user.id);
cmdInfo.Parameters.AddWithValue("@name", user.name);
cmdInfo.Parameters.AddWithValue("@name", user.name ?? user.username ?? username);
cmdInfo.Parameters.AddWithValue("@about", user.about);
cmdInfo.Parameters.AddWithValue("@expiresOn", user.subscribedByExpireDate);
cmdInfo.Parameters.AddWithValue("@photoCount", user.photosCount ?? 0);

View File

@ -15,6 +15,6 @@ namespace OF_DL.Helpers
Task<long> GetStoredFileSize(string folder, long media_id, string api_type);
Task<bool> CheckDownloaded(string folder, long media_id, string api_type);
Task<DateTime?> GetMostRecentPostDate(string folder);
Task UpdateUserInfo(User? user);
Task UpdateUserInfo(string username, User? user);
}
}

View File

@ -984,7 +984,7 @@ public class Program
{
Log.Information("Updating User Info for for: {Username:l}");
User? user_info = await m_ApiHelper.GetUserInfo($"/users/{username}");
await dbHelper.UpdateUserInfo(user_info);
await dbHelper.UpdateUserInfo(username, user_info);
}
catch (Exception ex)
{