Skip to content

Fix sync -H syncing the .cld-sync meta file - #131

Merged
const-cloudinary merged 3 commits into
masterfrom
fix/sync-ignore-meta-file
Oct 4, 2026
Merged

const-cloudinary merged 3 commits into
masterfrom
fix/sync-ignore-meta-file

Conversation

@const-cloudinary

Copy link
Copy Markdown
Member

sync keeps a .cld-sync meta file in the local folder. With -H / --include-hidden it was treated as a regular file.

Use cases fixed

Case Before this PR After
sync --push -H .cld-sync uploaded as a public raw asset, before it is updated, then out of sync on every later push Not uploaded
sync --pull -H --force, no .cld-sync on Cloudinary Local .cld-sync deleted as a unique local file Kept
sync --pull -H, .cld-sync pushed earlier Local .cld-sync overwritten with the remote copy Kept, remote copy not downloaded
.cld-sync of a subfolder synced separately (sub/.cld-sync) Same as above Same as above

Brief Summary of Changes

  • exclude_file(files, file_name) (cloudinary_cli/utils/file_utils.py): drops entries whose base name is file_name.
  • SyncDir.__init__ (cloudinary_cli/modules/sync.py): applies it with .cld-sync to the local and remote file lists.
  • 1 integration test in TestCLISync and 4 offline tests in TestCLISyncMetaFileOffline.

What does this PR address?

  • GitHub issue (Add reference - #XX)
  • Refactoring
  • New feature
  • Bug fix
  • Adds more tests

Are tests included?

  • Yes
  • No

Reviewer, please note:

  • A .cld-sync asset already pushed by an earlier version stays on Cloudinary: sync neither deletes nor downloads it.
  • The "Found N items in Cloudinary folder" log line still counts such an asset.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I ran the full test suite before pushing the changes and all the tests pass.

Tests not run yet.

🤖 Generated with Claude Code

const-cloudinary and others added 3 commits October 4, 2026 15:24
With `--include-hidden`, `walk_dir` returned the `.cld-sync` meta file as
a regular local file, so:
- `sync --push -H` uploaded it as a raw asset, before it was updated,
  and found it out of sync on every later push;
- `sync --pull -H` deleted the local meta file as unique, or overwrote
  it with a copy pushed earlier.

Add `exclude_file` to `file_utils` and drop `.cld-sync` files, at any
depth, from the local and remote file lists in `SyncDir`. A copy already
pushed by an earlier version is left on Cloudinary.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`delete_cld_folder_if_exists` called `delete_resources_by_prefix` with the
default `image` resource type, so raw files pushed by a test in fixed
folder mode were left behind and `delete_folder` failed with "Folder is
not empty" for every following test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The Search API indexes new assets with a delay, so counting remote assets
right after the push was flaky. `Synced | 2` already shows that the meta
file was not uploaded.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@const-cloudinary
const-cloudinary merged commit 3941b25 into master Oct 4, 2026
8 checks passed
@const-cloudinary
const-cloudinary deleted the fix/sync-ignore-meta-file branch October 4, 2026 14:19
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.

1 participant