From b9c6472e2a5f5797817f1410734cbc6fd6f00fbc Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Sat, 21 Jun 2025 17:58:57 +0700 Subject: [PATCH] [FIX] Save profile after create --- .../auth/profiles/LocalProfilesProvider.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/profiles/LocalProfilesProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/profiles/LocalProfilesProvider.java index 311c4453..8044c96b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/profiles/LocalProfilesProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/profiles/LocalProfilesProvider.java @@ -60,12 +60,7 @@ public UncompletedProfile create(String name, String description, CompletedProfi .setAssetDir("assets") .createClientProfile(), null, getUpdatesDir("assets")); } - profilesMap.put(profile.getUuid(), profile); - try(Writer writer = IOHelper.newWriter(profile.getConfigPath())) { - Launcher.gsonManager.configGson.toJson(profile.profile, writer); - } catch (IOException e) { - throw new RuntimeException(e); - } + pushProfileAndSave(profile); return profile; } @@ -103,10 +98,19 @@ public CompletedProfile pushUpdate(UncompletedProfile profile, String tag, Clien execute(localProfile.clientDir, clientDir, clientActions); localProfile.clientDir = new HashedDir(clientDir, null, true, true); } - profilesMap.put(localProfile.getUuid(), localProfile); + pushProfileAndSave(localProfile); return localProfile; } + private void pushProfileAndSave(LocalProfile localProfile) { + profilesMap.put(localProfile.getUuid(), localProfile); + try(Writer writer = IOHelper.newWriter(localProfile.getConfigPath())) { + Launcher.gsonManager.configGson.toJson(localProfile.profile, writer); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + @Override public void download(CompletedProfile profile, Map files, boolean assets) throws IOException { Path sourceDir = Path.of(updatesDir).resolve(assets ? profile.getProfile().getAssetDir() : profile.getProfile().getDir());