Duplicating a copy names it after the original; a failed duplicate or delete says why
This commit is contained in:
@@ -26,7 +26,13 @@ from pydantic import BaseModel, Field, field_validator, model_validator
|
||||
|
||||
from fluksio.flow.messages import DType, qualify
|
||||
from fluksio.flow.schemas import FlowDef, _validate_name
|
||||
from fluksio.flow.store import FlowStore, StaleVersion, _updated_at, checked
|
||||
from fluksio.flow.store import (
|
||||
FlowStore,
|
||||
StaleVersion,
|
||||
_updated_at,
|
||||
checked,
|
||||
copy_name,
|
||||
)
|
||||
|
||||
#: Sibling of the shared-node library, and likewise not a flow.
|
||||
DASHBOARD_DIR = "_dashboards"
|
||||
@@ -854,10 +860,7 @@ class DashboardStore:
|
||||
"""
|
||||
with self._lock, self.flows._write_lock:
|
||||
source = self.read(name, draft=True)
|
||||
new_name, count = f"{name}_copy", 1
|
||||
while self.exists(new_name):
|
||||
count += 1
|
||||
new_name = f"{name}_copy_{count}"
|
||||
new_name = copy_name(name, self.exists)
|
||||
copy = source.model_copy(
|
||||
update={
|
||||
"name": new_name,
|
||||
|
||||
Reference in New Issue
Block a user