Continuing with my plugin journey, I'm now looking...
# plugins
h
Continuing with my plugin journey, I'm now looking into getting a bunch of files stored on disk, renaming some of the dirs and then dumping them somewhere else My first attempt involved: 1. Create
Digest
of the source files' dir 2. Create a
DigestSubset
of the files that I need to rename + remove prefix + add new prefix 3. Create a
DigestSubset
of the rest of the files that I didn't need to rename 4. Merge both together 5. Change prefix to the new location However... things got complicated because I couldn't use the
!
operator on step 3 to get "the other files"
Here's roughly the code I'm using
Copy code
# create main digest
digest = await Get(
    Digest,
    PathGlobs(globs=[f'{src_path}/**']),
)

# extract digest for name substitution
digest_subset = await Get(
    Digest,
    DigestSubset(digest, PathGlobs([f'{name_placeholder}/*'])),
)
digest_subset = await Get(
    Digest,
    RemovePrefix(digest_subset, name_placeholder),
)
digest_subset = await Get(
    Digest,
    AddPrefix(digest_subset, new_name),
)

# extract digest files that don't need substitution
digest_norename = await Get(
    Digest,
    DigestSubset(digest, PathGlobs([f'!{name_placeholder}/*'])),
)

# merge digests
digest_final = await Get(
    Digest,
    MergeDigests([digest_norename, digest_subset]),
)
c
I've experienced inconsistent behaviour wrgt exclude patterns in the past. Some issues have been fixed, but I wouldn't be surprised if there are some more lingering. Usually those have been of a work-aroundable kind in my cases by tweaking the glob patterns, but it is icky. If you try to make the exclude less generic, if possible, that could help, other than that I don't exactly recall the nature I've run into. (i.e. if there's common file extensions or naming patterns, that could help)