added move action into asset workspace

This commit is contained in:
2026-03-24 13:42:47 +00:00
parent 29a2398b1d
commit bf4dc17469
24 changed files with 1651 additions and 387 deletions
@@ -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);
}
}