asset details (WIP)
This commit is contained in:
+51
-3
@@ -7,8 +7,11 @@ import p.packer.PackerWorkspacePaths;
|
||||
import p.packer.exceptions.PackerRegistryException;
|
||||
import p.packer.messages.PackerProjectContext;
|
||||
import p.packer.models.PackerAssetCacheEntry;
|
||||
import p.packer.models.PackerDiagnostic;
|
||||
import p.packer.models.PackerFileCacheEntry;
|
||||
import p.packer.models.PackerWorkspaceCacheState;
|
||||
import p.packer.messages.diagnostics.PackerDiagnosticCategory;
|
||||
import p.packer.messages.diagnostics.PackerDiagnosticSeverity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@@ -54,7 +57,8 @@ public final class FileSystemPackerCacheRepository {
|
||||
file.size,
|
||||
file.lastModified,
|
||||
file.fingerprint,
|
||||
file.metadata == null ? Map.of() : file.metadata));
|
||||
file.metadata == null ? Map.of() : file.metadata,
|
||||
loadDiagnostics(file.diagnostics)));
|
||||
}
|
||||
}
|
||||
validateAssetId(asset.assetId);
|
||||
@@ -92,7 +96,8 @@ public final class FileSystemPackerCacheRepository {
|
||||
file.size(),
|
||||
file.lastModified(),
|
||||
file.fingerprint(),
|
||||
file.metadata()))
|
||||
file.metadata(),
|
||||
saveDiagnostics(file.diagnostics())))
|
||||
.toList()))
|
||||
.toList();
|
||||
mapper.writerWithDefaultPrettyPrinter().writeValue(cachePath.toFile(), document);
|
||||
@@ -101,6 +106,39 @@ public final class FileSystemPackerCacheRepository {
|
||||
}
|
||||
}
|
||||
|
||||
private List<PackerDiagnostic> loadDiagnostics(List<CacheDiagnosticDocument> diagnostics) {
|
||||
if (diagnostics == null || diagnostics.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
final List<PackerDiagnostic> loaded = new ArrayList<>();
|
||||
for (CacheDiagnosticDocument diagnostic : diagnostics) {
|
||||
if (diagnostic == null || diagnostic.severity == null || diagnostic.category == null || diagnostic.message == null) {
|
||||
continue;
|
||||
}
|
||||
loaded.add(new PackerDiagnostic(
|
||||
diagnostic.severity,
|
||||
diagnostic.category,
|
||||
diagnostic.message,
|
||||
diagnostic.evidencePath == null || diagnostic.evidencePath.isBlank() ? null : Path.of(diagnostic.evidencePath),
|
||||
diagnostic.blocking));
|
||||
}
|
||||
return List.copyOf(loaded);
|
||||
}
|
||||
|
||||
private List<CacheDiagnosticDocument> saveDiagnostics(List<PackerDiagnostic> diagnostics) {
|
||||
if (diagnostics == null || diagnostics.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
return diagnostics.stream()
|
||||
.map(diagnostic -> new CacheDiagnosticDocument(
|
||||
diagnostic.severity(),
|
||||
diagnostic.category(),
|
||||
diagnostic.message(),
|
||||
diagnostic.evidencePath() == null ? null : diagnostic.evidencePath().toString(),
|
||||
diagnostic.blocking()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
private void validateDuplicateAssetIds(List<PackerAssetCacheEntry> assets) {
|
||||
final Set<Integer> assetIds = new HashSet<>();
|
||||
for (PackerAssetCacheEntry asset : assets) {
|
||||
@@ -162,6 +200,16 @@ public final class FileSystemPackerCacheRepository {
|
||||
@JsonProperty("size") long size,
|
||||
@JsonProperty("last_modified") long lastModified,
|
||||
@JsonProperty("fingerprint") String fingerprint,
|
||||
@JsonProperty("metadata") Map<String, Object> metadata) {
|
||||
@JsonProperty("metadata") Map<String, Object> metadata,
|
||||
@JsonProperty("diagnostics") List<CacheDiagnosticDocument> diagnostics) {
|
||||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
private record CacheDiagnosticDocument(
|
||||
@JsonProperty("severity") PackerDiagnosticSeverity severity,
|
||||
@JsonProperty("category") PackerDiagnosticCategory category,
|
||||
@JsonProperty("message") String message,
|
||||
@JsonProperty("evidence_path") String evidencePath,
|
||||
@JsonProperty("blocking") boolean blocking) {
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -73,7 +73,10 @@ public abstract class PackerAbstractBankWalker<R> {
|
||||
final var fileProbe = fileProbeMaybe.get();
|
||||
final var cachedEntry = resolvePriorFileCache(assetRoot, fileProbe.path(), priorAssetCache);
|
||||
if (cachedEntry.isPresent() && canReuseMetadata(fileProbe, cachedEntry.get())) {
|
||||
probeResults.add(new PackerProbeResult(fileProbe, cachedEntry.get().metadata(), List.of()));
|
||||
probeResults.add(new PackerProbeResult(
|
||||
fileProbe,
|
||||
cachedEntry.get().metadata(),
|
||||
cachedEntry.get().diagnostics()));
|
||||
continue;
|
||||
}
|
||||
probeResults.add(processFileProbe(fileProbe, requirements));
|
||||
|
||||
+2
-1
@@ -74,7 +74,8 @@ public final class PackerRuntimeAssetMaterializer {
|
||||
file.size(),
|
||||
file.lastModified(),
|
||||
file.fingerprint(),
|
||||
file.metadata()))
|
||||
file.metadata(),
|
||||
file.diagnostics()))
|
||||
.toList());
|
||||
return new PackerRuntimeAssetMaterialization(runtimeAsset, Optional.of(assetCacheEntry));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user