Skip to content

Commit ad63218

Browse files
committed
[FIX] Fix bugs with RemoteProfilesProvider
1 parent f7bda2f commit ad63218

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

components/launchserver/src/main/java/pro/gravit/launchserver/auth/profiles/RemoteProfilesProvider.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package pro.gravit.launchserver.auth.profiles;
22

3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
35
import pro.gravit.launcher.base.Downloader;
46
import pro.gravit.launcher.base.HttpHelper;
57
import pro.gravit.launcher.base.profiles.ClientProfile;
@@ -25,6 +27,7 @@
2527
import java.util.stream.Collectors;
2628

2729
public class RemoteProfilesProvider extends ProfilesProvider {
30+
private static final Logger log = LoggerFactory.getLogger(RemoteProfilesProvider.class);
2831
public String baseUrl = "PASTE BASE URL HERE";
2932
public String accessToken = "PASTE ACCESS TOKEN HERE";
3033
private final transient HttpClient client = HttpClient.newBuilder().build();
@@ -134,9 +137,9 @@ public void download(CompletedProfile profile, Map<String, Path> files, boolean
134137
HttpProfile httpProfile = (HttpProfile) profile;
135138
HashedDir dir;
136139
if(assets) {
137-
dir = httpProfile.assetDir;
140+
dir = httpProfile.assets;
138141
} else {
139-
dir = httpProfile.clientDir;
142+
dir = httpProfile.client;
140143
}
141144
List<Downloader.SizedFile> sizedFiles = new ArrayList<>();
142145
for(var e : files.entrySet()) {
@@ -164,8 +167,22 @@ public void download(CompletedProfile profile, Map<String, Path> files, boolean
164167
return HashedDir.WalkAction.CONTINUE;
165168
});
166169
}
170+
} else {
171+
dir.walk("/", (rpath, name, entry) -> {
172+
if(entry instanceof HashedFile file) {
173+
Path target = path.resolve(rpath);
174+
try {
175+
IOHelper.createParentDirs(target);
176+
} catch (IOException ex) {
177+
throw new RuntimeException(ex);
178+
}
179+
sizedFiles.add(new Downloader.SizedFile(file.url, target.toString(), file.size()));
180+
}
181+
return HashedDir.WalkAction.CONTINUE;
182+
});
167183
}
168184
}
185+
log.info("Download {} files", sizedFiles.size());
169186
try {
170187
Command.downloadWithProgressBar("files", sizedFiles, "https://example.com", Path.of(""));
171188
} catch (Exception e) {
@@ -320,7 +337,7 @@ public String getDefaultTag() {
320337
}
321338
}
322339

323-
public record HttpProfile(ClientProfile profile, HashedDir clientDir, HashedDir assetDir) implements CompletedProfile {
340+
public record HttpProfile(ClientProfile profile, HashedDir client, HashedDir assets) implements CompletedProfile {
324341

325342
@Override
326343
public String getTag() {
@@ -334,12 +351,12 @@ public ClientProfile getProfile() {
334351

335352
@Override
336353
public HashedDir getClientDir() {
337-
return clientDir;
354+
return client;
338355
}
339356

340357
@Override
341358
public HashedDir getAssetDir() {
342-
return assetDir;
359+
return assets;
343360
}
344361

345362
@Override

0 commit comments

Comments
 (0)