fix: pool profiles never auto-switch on connect; seed empty profile from current pool
Connecting a Pool Profile no longer overwrites the pool's pool_id. The pool is switched only when the user actively selects a profile in the dropdown; picking an empty profile while a pool with images is connected offers to copy those images into it (new seed_profile op + /grid_pool/profiles/seed route), so the current pool is never silently lost. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -114,6 +114,26 @@ def export_profile(base, pid, dest_zip):
|
||||
return dest_zip
|
||||
|
||||
|
||||
def seed_profile(base, from_id, profile_id):
|
||||
"""Copy a pool dir's files (images/masks/manifest) into a profile dir.
|
||||
|
||||
Used to save an Image Pool's current contents into a freshly-selected empty
|
||||
profile. Copies top-level files only (the pool layout is flat); returns the
|
||||
number of files copied. No-op (0) if the source dir is missing.
|
||||
"""
|
||||
src = Path(base) / from_id
|
||||
dst = Path(base) / profile_id
|
||||
if not src.exists():
|
||||
return 0
|
||||
dst.mkdir(parents=True, exist_ok=True)
|
||||
n = 0
|
||||
for f in src.iterdir():
|
||||
if f.is_file():
|
||||
shutil.copy2(f, dst / f.name)
|
||||
n += 1
|
||||
return n
|
||||
|
||||
|
||||
def import_profile(base, src_zip, new_id, name=None, ts=0):
|
||||
reg = read_registry(base)
|
||||
meta_name = None
|
||||
|
||||
Reference in New Issue
Block a user