Fix copy-merge to preserve locally-added files in upstream-deleted directories - #4720
Merged
Conversation
…rectories Signed-off-by: Kushal Harish Naidu <kushal.harish.naidu@ericsson.com>
kushnaidu
requested review from
efiacor,
kispaljr,
liamfallon and
mozesl-nokia
as code owners
August 31, 2026 14:44
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
kushnaidu
force-pushed
the
copy-merge-preserve-lf
branch
from
August 31, 2026 14:58
551347d to
6fac6dc
Compare
Signed-off-by: Kushal Harish Naidu <kushal.harish.naidu@ericsson.com>
kushnaidu
force-pushed
the
copy-merge-preserve-lf
branch
from
August 31, 2026 15:21
6fac6dc to
a7fcba1
Compare
efiacor
approved these changes
Sep 1, 2026
liamfallon
approved these changes
Sep 2, 2026
liamfallon
left a comment
Contributor
There was a problem hiding this comment.
Looks good. Please fix the typo spotted by @efiacor
Signed-off-by: Kushal Harish Naidu <kushal.harish.naidu@ericsson.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



When the upstream revision deletes a directory that still contains files added only in the downstream package, RemoveStaleItems failed with "directory not empty" because it used os.Remove (non-recursive) on directories that legitimately had local content remaining.
This surfaced as an Internal error from the Porch API server during porchctl rpkg upgrade --strategy=copy-merge.
The fix checks whether each stale directory is empty before removing it, consistent with the copy-merge spec: "files that only exist locally are kept." Stale files inside the directory are still removed, but locally-added files and their parent directories are preserved.
The approach mirrors RemovePackageContent in the same file, which already uses Readdirnames(1) to verify emptiness before deletion.