Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compat: Add "all" arch packages to arch specific indexes too #103

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.TimeZone;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import javax.inject.Named;

Expand Down Expand Up @@ -86,6 +88,8 @@ public class OrientAptHostedFacet
private static final String P_PACKAGE_NAME = "package_name";
private static final String P_PACKAGE_VERSION = "package_version";

private static final String ALL_ARCHITECTURE = "all";

private static final String SELECT_HOSTED_ASSETS =
"SELECT " +
"name, " +
Expand Down Expand Up @@ -217,7 +221,12 @@ private CompressingTempFileStore buildPackageIndexes(final StorageTx tx, final B
Set<String> excludeNames = changes.stream().map(change -> change.asset.name()).collect(Collectors.toSet());

Iterable<ODocument> browse = tx.browse(SELECT_HOSTED_ASSETS, sqlParams);
TreeSet<String> archs = StreamSupport.stream(browse.spliterator(), false)
.map(document -> document.<String>field(P_ARCHITECTURE, String.class))
.filter(arch -> !ALL_ARCHITECTURE.equals(arch))
.collect(Collectors.toCollection(TreeSet::new));

browse = tx.browse(SELECT_HOSTED_ASSETS, sqlParams);
for (ODocument document : browse) {
String name = document.field(P_NAME, String.class);
String arch = document.field(P_ARCHITECTURE, String.class);
Expand All @@ -226,6 +235,14 @@ private CompressingTempFileStore buildPackageIndexes(final StorageTx tx, final B
String indexSection = document.field(P_INDEX_SECTION, String.class);
outWriter.write(indexSection);
outWriter.write("\n\n");

if (ALL_ARCHITECTURE.equals(arch)) {
for (String foreignArch: archs) {
Writer foreignOutWriter = streams.computeIfAbsent(foreignArch, result::openOutput);
foreignOutWriter.write(indexSection);
foreignOutWriter.write("\n\n");
}
}
}
}

Expand All @@ -239,6 +256,14 @@ private CompressingTempFileStore buildPackageIndexes(final StorageTx tx, final B
Writer outWriter = streams.computeIfAbsent(arch, result::openOutput);
outWriter.write(indexSection);
outWriter.write("\n\n");

if (ALL_ARCHITECTURE.equals(arch)) {
for (String foreignArch: archs) {
Writer foreignOutWriter = streams.computeIfAbsent(foreignArch, result::openOutput);
foreignOutWriter.write(indexSection);
foreignOutWriter.write("\n\n");
}
}
}
ok = true;
}
Expand Down