[FIX] Save profile after create

This commit is contained in:
Gravita 2025-06-21 17:58:57 +07:00
parent 230fd22f99
commit b9c6472e2a

View file

@ -60,12 +60,7 @@ public UncompletedProfile create(String name, String description, CompletedProfi
.setAssetDir("assets") .setAssetDir("assets")
.createClientProfile(), null, getUpdatesDir("assets")); .createClientProfile(), null, getUpdatesDir("assets"));
} }
profilesMap.put(profile.getUuid(), profile); pushProfileAndSave(profile);
try(Writer writer = IOHelper.newWriter(profile.getConfigPath())) {
Launcher.gsonManager.configGson.toJson(profile.profile, writer);
} catch (IOException e) {
throw new RuntimeException(e);
}
return profile; return profile;
} }
@ -103,10 +98,19 @@ public CompletedProfile pushUpdate(UncompletedProfile profile, String tag, Clien
execute(localProfile.clientDir, clientDir, clientActions); execute(localProfile.clientDir, clientDir, clientActions);
localProfile.clientDir = new HashedDir(clientDir, null, true, true); localProfile.clientDir = new HashedDir(clientDir, null, true, true);
} }
profilesMap.put(localProfile.getUuid(), localProfile); pushProfileAndSave(localProfile);
return 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 @Override
public void download(CompletedProfile profile, Map<String, Path> files, boolean assets) throws IOException { public void download(CompletedProfile profile, Map<String, Path> files, boolean assets) throws IOException {
Path sourceDir = Path.of(updatesDir).resolve(assets ? profile.getProfile().getAssetDir() : profile.getProfile().getDir()); Path sourceDir = Path.of(updatesDir).resolve(assets ? profile.getProfile().getAssetDir() : profile.getProfile().getDir());