Skip to content

Commit

Permalink
remove sleeps
Browse files Browse the repository at this point in the history
  • Loading branch information
silvajp2 committed Aug 2, 2023
1 parent 5c6ffd4 commit 914ef64
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'io.github.netmikey.mvncloner'
version = '1.0.2-SNAPSHOT'
version = '1.0.3-SNAPSHOT'
sourceCompatibility = '11'

repositories {
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/io/github/netmikey/mvncloner/mvncloner/Publisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void publish() throws Exception {
}

public void publishDirectory(HttpClient httpClient, String repositoryUrl, Path mirrorPath)
throws IOException, InterruptedException {
throws IOException, InterruptedException {

LOG.debug("Switching to mirror directory: " + mirrorPath.toAbsolutePath());

Expand All @@ -74,23 +74,23 @@ public void publishDirectory(HttpClient httpClient, String repositoryUrl, Path m
}

private void handleFile(HttpClient httpClient, String repositoryUrl, Path path)
throws IOException, InterruptedException {
throws IOException, InterruptedException {

String filename = path.getFileName().toString();
String targetUrl = repositoryUrl + filename;
LOG.info("Uploading " + targetUrl);

Utils.sleep(1000);
// Utils.sleep(1000);
HttpRequest request = Utils.setCredentials(HttpRequest.newBuilder(), username, password)
.uri(URI.create(targetUrl))
.PUT(BodyPublishers.ofInputStream(() -> {
try {
return Files.newInputStream(path, StandardOpenOption.READ);
} catch (IOException e) {
throw new RuntimeException(e);
}
}))
.build();
.uri(URI.create(targetUrl))
.PUT(BodyPublishers.ofInputStream(() -> {
try {
return Files.newInputStream(path, StandardOpenOption.READ);
} catch (IOException e) {
throw new RuntimeException(e);
}
}))
.build();
HttpResponse<String> response = httpClient.send(request, BodyHandlers.ofString());
if (response.statusCode() < 200 || response.statusCode() > 299) {
LOG.error("Error uploading " + targetUrl + " : Response code was " + response.statusCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public class Scraper {
private static final Pattern FILE_URL_PATTERN = Pattern.compile("^.*/([^/]+\\.([^\\./]{1,6}))$");

private static Set<String> EXTENSION_BLACKLIST = new HashSet<>(
Arrays.asList("md5", "sha1", "asc", "sha256", "sha512"));
Arrays.asList("md5", "sha1", "asc", "sha256", "sha512"));

private static Set<String> FILENAME_BLACKLIST = new HashSet<>(
Arrays.asList("maven-metadata.xml", "archetype-catalog.xml"));
Arrays.asList("maven-metadata.xml", "archetype-catalog.xml"));

@Value("${source.root-url}")
private String rootUrl;
Expand All @@ -71,7 +71,7 @@ public void mirror() throws Exception {
InetSocketAddress proxyAddress = (InetSocketAddress) theProxy.address();
if (proxyAddress != null) {
webClient.getOptions()
.setProxyConfig(new ProxyConfig(proxyAddress.getHostName(), proxyAddress.getPort()));
.setProxyConfig(new ProxyConfig(proxyAddress.getHostName(), proxyAddress.getPort()));
}
});
// Set credentials
Expand All @@ -86,7 +86,7 @@ public void mirror() throws Exception {
}

private void processIndexUrl(WebClient webClient, String pageUrl, Path mirrorPath)
throws IOException, URISyntaxException {
throws IOException, URISyntaxException {
LOG.debug("Switching to mirror directory: " + mirrorPath.toAbsolutePath().toString());
Files.createDirectories(mirrorPath);

Expand Down Expand Up @@ -130,7 +130,7 @@ private void processIndexUrl(WebClient webClient, String pageUrl, Path mirrorPat
URI base = new URI(pageUrl);
String relativePath = StringUtils.strip(base.relativize(new URI(fullyQualifiedUrl)).toString(), "/ ");
LOG.debug(" Recursing into: " + relativePath);
Utils.sleep(1000);
// Utils.sleep(1000);
processIndexUrl(webClient, fullyQualifiedUrl, mirrorPath.resolve(relativePath));
}
}
Expand All @@ -150,7 +150,7 @@ private void handleFileLink(WebClient webClient, Path mirrorPath, Matcher filePa
if (Files.exists(targetFile)) {
LOG.debug(" File already exists, skipping download: " + targetFile);
} else {
Utils.sleep(500);
// Utils.sleep(500);
LOG.info(" Downloading: " + fullyQualifiedUrl);
Page page = webClient.getPage(fullyQualifiedUrl);
Files.copy(page.getWebResponse().getContentAsStream(), targetFile);
Expand Down

0 comments on commit 914ef64

Please sign in to comment.