fix: does not remove the old library when updating the library
This commit is contained in:
@@ -33,6 +33,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.download.LibraryAnalyzer.LibraryType.OPTIFINE;
|
import static org.jackhuang.hmcl.download.LibraryAnalyzer.LibraryType.OPTIFINE;
|
||||||
|
|
||||||
@@ -130,9 +131,14 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
|||||||
public Task<Version> installLibraryAsync(Version baseVersion, RemoteVersion libraryVersion) {
|
public Task<Version> installLibraryAsync(Version baseVersion, RemoteVersion libraryVersion) {
|
||||||
if (baseVersion.isResolved()) throw new IllegalArgumentException("Version should not be resolved");
|
if (baseVersion.isResolved()) throw new IllegalArgumentException("Version should not be resolved");
|
||||||
|
|
||||||
|
AtomicReference<Version> removedLibraryVersion = new AtomicReference<>();
|
||||||
|
|
||||||
return removeLibraryAsync(baseVersion.resolvePreservingPatches(repository), libraryVersion.getLibraryId())
|
return removeLibraryAsync(baseVersion.resolvePreservingPatches(repository), libraryVersion.getLibraryId())
|
||||||
.thenComposeAsync(version -> libraryVersion.getInstallTask(this, version))
|
.thenComposeAsync(version -> {
|
||||||
.thenApplyAsync(baseVersion::addPatch)
|
removedLibraryVersion.set(version);
|
||||||
|
return libraryVersion.getInstallTask(this, version);
|
||||||
|
})
|
||||||
|
.thenApplyAsync(patch -> removedLibraryVersion.get().addPatch(patch))
|
||||||
.withStage(String.format("hmcl.install.%s:%s", libraryVersion.getLibraryId(), libraryVersion.getSelfVersion()));
|
.withStage(String.format("hmcl.install.%s:%s", libraryVersion.getLibraryId(), libraryVersion.getSelfVersion()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user