added contract update into asset workspace
This commit is contained in:
+35
-11
@@ -1,17 +1,9 @@
|
||||
package p.packer.services;
|
||||
|
||||
import p.packer.models.PackerAssetDeclarationParseResult;
|
||||
import p.packer.models.PackerRegistryEntry;
|
||||
import p.packer.models.PackerRegistryState;
|
||||
import p.packer.models.PackerRuntimeAsset;
|
||||
import p.packer.models.PackerRuntimeSnapshot;
|
||||
import p.packer.models.*;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
public final class PackerRuntimePatchService {
|
||||
private final PackerAssetDeclarationParser declarationParser;
|
||||
@@ -81,7 +73,7 @@ public final class PackerRuntimePatchService {
|
||||
PackerRuntimeSnapshot snapshot,
|
||||
long generation,
|
||||
PackerRegistryState updatedRegistry,
|
||||
java.util.Optional<PackerRegistryEntry> updatedRegistryEntry,
|
||||
Optional<PackerRegistryEntry> updatedRegistryEntry,
|
||||
Path sourceRoot,
|
||||
Path targetRoot,
|
||||
Path targetManifestPath) {
|
||||
@@ -106,4 +98,36 @@ public final class PackerRuntimePatchService {
|
||||
updatedAssets.sort(Comparator.comparing(asset -> asset.assetRoot().toString(), String.CASE_INSENSITIVE_ORDER));
|
||||
return new PackerRuntimeSnapshot(generation, updatedRegistry, updatedAssets);
|
||||
}
|
||||
|
||||
public PackerRuntimeSnapshot afterUpdateAssetContract(
|
||||
PackerRuntimeSnapshot snapshot,
|
||||
long generation,
|
||||
Path assetRoot,
|
||||
Path manifestPath,
|
||||
Optional<PackerRegistryEntry> registryEntry) {
|
||||
final PackerAssetDeclarationParseResult parsed = declarationParser.parse(manifestPath);
|
||||
final List<PackerRuntimeAsset> updatedAssets = new ArrayList<>();
|
||||
boolean patched = false;
|
||||
for (PackerRuntimeAsset asset : snapshot.assets()) {
|
||||
if (asset.assetRoot().equals(assetRoot.toAbsolutePath().normalize())) {
|
||||
updatedAssets.add(new PackerRuntimeAsset(
|
||||
asset.assetRoot(),
|
||||
asset.manifestPath(),
|
||||
asset.registryEntry(),
|
||||
parsed));
|
||||
patched = true;
|
||||
} else {
|
||||
updatedAssets.add(asset);
|
||||
}
|
||||
}
|
||||
if (!patched) {
|
||||
updatedAssets.add(new PackerRuntimeAsset(
|
||||
assetRoot,
|
||||
manifestPath,
|
||||
registryEntry,
|
||||
parsed));
|
||||
updatedAssets.sort(Comparator.comparing(asset -> asset.assetRoot().toString(), String.CASE_INSENSITIVE_ORDER));
|
||||
}
|
||||
return new PackerRuntimeSnapshot(generation, snapshot.registry(), updatedAssets);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user