added move action into asset workspace
This commit is contained in:
+30
@@ -76,4 +76,34 @@ public final class PackerRuntimePatchService {
|
||||
.toList();
|
||||
return new PackerRuntimeSnapshot(generation, updatedRegistry, updatedAssets);
|
||||
}
|
||||
|
||||
public PackerRuntimeSnapshot afterMoveAsset(
|
||||
PackerRuntimeSnapshot snapshot,
|
||||
long generation,
|
||||
PackerRegistryState updatedRegistry,
|
||||
java.util.Optional<PackerRegistryEntry> updatedRegistryEntry,
|
||||
Path sourceRoot,
|
||||
Path targetRoot,
|
||||
Path targetManifestPath) {
|
||||
final PackerAssetDeclarationParseResult parsed = declarationParser.parse(targetManifestPath);
|
||||
final List<PackerRuntimeAsset> updatedAssets = new ArrayList<>();
|
||||
boolean patched = false;
|
||||
for (PackerRuntimeAsset asset : snapshot.assets()) {
|
||||
if (asset.assetRoot().equals(sourceRoot.toAbsolutePath().normalize())) {
|
||||
updatedAssets.add(new PackerRuntimeAsset(
|
||||
targetRoot,
|
||||
targetManifestPath,
|
||||
updatedRegistryEntry,
|
||||
parsed));
|
||||
patched = true;
|
||||
} else {
|
||||
updatedAssets.add(asset);
|
||||
}
|
||||
}
|
||||
if (!patched) {
|
||||
throw new IllegalStateException("Unable to patch runtime snapshot for moved asset: " + sourceRoot);
|
||||
}
|
||||
updatedAssets.sort(Comparator.comparing(asset -> asset.assetRoot().toString(), String.CASE_INSENSITIVE_ORDER));
|
||||
return new PackerRuntimeSnapshot(generation, updatedRegistry, updatedAssets);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user