Skip to content

Fix copy-merge to preserve locally-added files in upstream-deleted directories - #4720

Merged
efiacor merged 3 commits into
kptdev:mainfrom
Nordix:copy-merge-preserve-lf
Sep 2, 2026
Merged

Fix copy-merge to preserve locally-added files in upstream-deleted directories#4720
efiacor merged 3 commits into
kptdev:mainfrom
Nordix:copy-merge-preserve-lf

Conversation

@kushnaidu

@kushnaidu kushnaidu commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

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.

…rectories

Signed-off-by: Kushal Harish Naidu <kushal.harish.naidu@ericsson.com>
@netlify

netlify Bot commented Aug 31, 2026

Copy link
Copy Markdown

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit cdb5942
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6a97dab54231fa0008b8673c
😎 Deploy Preview https://deploy-preview-4720--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@kushnaidu
kushnaidu force-pushed the copy-merge-preserve-lf branch from 551347d to 6fac6dc Compare August 31, 2026 14:58
Signed-off-by: Kushal Harish Naidu <kushal.harish.naidu@ericsson.com>
@kushnaidu
kushnaidu force-pushed the copy-merge-preserve-lf branch from 6fac6dc to a7fcba1 Compare August 31, 2026 15:21
Comment thread pkg/lib/pkg/util.go Outdated

@liamfallon liamfallon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Please fix the typo spotted by @efiacor

Signed-off-by: Kushal Harish Naidu <kushal.harish.naidu@ericsson.com>
@sonarqubecloud

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

@efiacor
efiacor merged commit 1e5fc01 into kptdev:main Sep 2, 2026
27 checks passed
@efiacor
efiacor deleted the copy-merge-preserve-lf branch September 2, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants