Skip to content

Commit 34cc775

Browse files
committed
[FEATURE] Support download file by custom url
1 parent 79509ab commit 34cc775

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

components/launcher-api/src/main/java/pro/gravit/launcher/base/Downloader.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ protected DownloadTask sendAsync(SizedFile file, URI baseUri, Path targetDir, Do
235235
}
236236

237237
public static URI makeURI(URI baseUri, String filePath) throws URISyntaxException {
238+
if(filePath.startsWith("http://") || filePath.startsWith("https://")) {
239+
return URI.create(filePath);
240+
}
238241
URI uri;
239242
if(baseUri != null) {
240243
String scheme = baseUri.getScheme();

components/launcher-runtime/src/main/java/pro/gravit/launcher/runtime/backend/ClientDownloadImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@ private List<Downloader.SizedFile> collectFilesAndCreateDirectories(Path dir, Ha
187187
return HashedDir.WalkAction.CONTINUE;
188188
}
189189
String pathFixed = path.replace(File.separatorChar, '/');
190-
files.add(new Downloader.SizedFile(pathFixed, pathRemapper.apply(pathFixed), entry.size()));
190+
if(entry instanceof HashedFile hfile && hfile.url != null) {
191+
files.add(new Downloader.SizedFile(pathFixed, hfile.url, entry.size()));
192+
} else {
193+
files.add(new Downloader.SizedFile(pathFixed, pathRemapper.apply(pathFixed), entry.size()));
194+
}
191195
return HashedDir.WalkAction.CONTINUE;
192196
});
193197
return files;

0 commit comments

Comments
 (0)