This commit is contained in:
Minecon724 2024-10-24 13:50:24 +02:00
parent 7142d46849
commit 2f5d109aa8
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
2 changed files with 18 additions and 10 deletions

View file

@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.NoSuchFileException;
import java.security.SignatureException;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
@ -28,10 +29,17 @@ public class Updater {
public Environment getEnvironment() {
return environment;
}
/**
* Get all channels
* @return A future which returns the list of all channels
*/
public CompletableFuture<List<String>> getChannels() { return metadataProvider.getChannels(); }
/**
* get the latest available version
* @return a future which can throw ioexpception
* Get the latest available version
* @return A future which returns latest version metadata
*/
public CompletableFuture<Version> getLatestVersion() {
CompletableFuture<Version> currentVersionFuture = metadataProvider.getCurrentVersionMetadata();
@ -49,16 +57,16 @@ public class Updater {
}
/**
* get information about this version
* @return a future which can throw ioexpception
* Get information about this version
* @return A future which returns current version metadata
*/
public CompletableFuture<Version> getCurrentVersion() {
return metadataProvider.getCurrentVersionMetadata();
}
/**
* download the latest available version
* @return a future which returns the downloaded file, it can also throw ioexpception or signatureexception
* Download the latest available version
* @return a future which returns the downloaded file
*/
public CompletableFuture<File> downloadLatestVersion() {
CompletableFuture<Version> latestVersionFuture = metadataProvider.getLatestVersionMetadata();
@ -75,9 +83,9 @@ public class Updater {
}
/**
* installs the ALREADY DOWNLOADED latest version
* you can call it immediately after {@link #downloadLatestVersion()}
* @return a {@link CompletableFuture} that ends after move. it can throw
* Installs the ALREADY DOWNLOADED latest version<br>
* You can call it immediately after {@link #downloadLatestVersion()}
* @return a {@link CompletableFuture} that ends after move, it can throw some exceptions.
* @throws NoSuchFileException if you didn't download it first
*/
public CompletableFuture<Void> installLatestVersion() throws NoSuchFileException {

View file

@ -43,7 +43,7 @@ public class GiteaMetadataDAO implements MetadataDAO {
@Override
public CompletableFuture<Version> getMetadata(String channel, String versionLabel) {
String url = getFileUrl(versionLabel, "meta-v1.json");
String url = getFileUrl(channel, versionLabel, "meta-v1.json");
CompletableFuture<Version> metadataFuture =
makeRequest(url).thenApply(response -> {