Skip to content

fix: keep a copied project out of the original's directory when their sanitized names collide - #752

Open
pcbeingused333 wants to merge 1 commit into
QuantConnect:masterfrom
pcbeingused333:c4323-sanitized-collision
Open

pcbeingused333 wants to merge 1 commit into
QuantConnect:masterfrom
pcbeingused333:c4323-sanitized-collision

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #740

When a project without a cloud ID is pushed, get_local_project_path looks for its destination directory and accepts any existing directory whose local-id matches. A copy of a project keeps the local-id of its original, so if sanitizing the copy's name selects the original's directory, that directory is taken as the destination. shutil.move then nests the copy inside it, the push reads the original's config, assigns the new cloud ID to it, and uploads the original's files.

The local-id match is now limited to the pushed project's own directory (source_path). A different directory that merely shares the local ID is treated as taken, and the next free name (Python Project 2) is used, so both projects keep their contents and cloud IDs.

Test: a copy Python:Project sharing the local ID of Python Project (cloud ID 10) is pushed. It fails before the change (the original's cloud ID becomes 20) and passes after; it also checks that the original's files are unchanged and that the copy's own files are uploaded to project 20.

This change was prepared with assistance from an AI coding tool.

… sanitized names collide

A copy that keeps the local-id of its original was matched by local id to the original's directory, so the push moved the copy inside it and assigned the new cloud id to the original. Only the pushed project's own directory may be matched by local id now.
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.

Pushing a copied project can overwrite the original's cloud identity on a sanitized-name collision

1 participant