mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-01 09:22:58 -05:00
# Description Deleting a custom printer preset queued every compatible system filament for a cloud delete. These ids can never name a cloud profile, so OrcaSlicer resent each one about once a minute for as long as it ran. Deletes for profiles the signed-in account doesn't have were also resent forever, even across restarts. After an account switch, a pending delete could go out with the other account's token. With this change: - Only the user's own presets are queued. - A delete is finished once the server confirms the profile is gone or there was nothing to delete. - Network failures are no longer mistaken for "not found". - Other failures wait longer between attempts, up to an hour. - A delete is only ever sent with its own account's token. - A delete still pending when OrcaSlicer quits is sent at the next start. That includes a custom printer's, which were missed before. Deleting a custom printer also deleted every user filament and process preset that worked with it, including presets with no printer restriction that other printers use. It now deletes only the presets made for that printer alone, and the confirmation dialog counts exactly those. - **Inherited presets stay.** A preset made for the printer is kept if a kept preset inherits from it, so the kept preset still loads. - **Copies of bundle presets count as the printer's own.** Presets copied from a bundle's when the printer was created are treated like the printer's other presets. Saving another preset's settings over an existing synced preset deleted that preset's cloud profile right after uploading the replacement. Other devices then dropped the preset until the saving device restarted. The replacement now takes over the profile and updates it. When the update gives a preset with no parent a parent, or takes it away, other devices move the preset's file instead of keeping a second copy. Subscription polls downloaded the whole subscription list every minute, although the gateway can answer 304 Not Modified when it hasn't changed. Each poll now asks whether the list the signed-in account received last is still current, and reuses it when it is. One account's list is never reused for another, or kept after signing out. There is no change to slicing. # Screenshots/Recordings/Graphs <!-- > Please attach relevant screenshots to showcase the UI changes. > Please attach images that can help explain the changes. --> ## Tests **Built:** macOS arm64 Release, with the app and the test suite. **New unit tests**, in `tests/slic3rutils/test_cloud_delete_queue.cpp` and new cases in `test_orca_cloud_agent.cpp`: - **What they cover:** - ownership of each delete, and account switches, including one in the middle of a request; - the retry waits; - the scan for deletes left over from an earlier run, custom printers' among them, and cleanup of their `.info` files. - **How the agent cases run:** against a local HTTP server, with real requests. They also cover a token refresh that switches the session to another account during a retry. - **Results:** - All 19 queue test cases and all 29 cloud agent test cases pass, in random order. - Most of the new tests use code this PR adds, so they can't build without it. **New subscription tests**, in `test_orca_cloud_agent.cpp`, cover: - a 304 answer reusing the list received last; - a changed list replacing it; - a list never being revalidated for another account, or after signing out. **New preset tests**, in `tests/libslic3r/test_preset_bundle_loading.cpp`, check: - which presets go with a deleted printer; - that a preset a kept preset inherits from stays; - that a preset copied from a bundle's for a new printer is the user's own; - that saving another preset over a synced preset keeps its cloud profile, and leaves no `.info` that would turn into a delete; - that a cloud update giving a root preset a parent leaves no copy of it in `base`. They and all `[Preset]` test cases pass in random order: 202 on macOS and the 198 that build on Windows. **Full `slic3rutils` suite, without the Python tests:** passes, except `JPEG texture decoding coexists with thumbnails and video frames`. It fails the same way on its own and doesn't touch this code. **Full `libslic3r` suite:** passes, except two `[TextureImport]` cases that decode JPEGs. They fail the same way on `main`. **Run by hand on two machines**, macOS arm64 and Windows 11 arm64, signed in to the same Orca Cloud account against api.orcaslicer.com. Both machines ran `c34532ae`. Results: - **Deleting a custom printer:** - The printer had a filament and a process made for it alone. It also had a filament made for it alone that an unrestricted filament inherits from. - The dialog said "1 filament preset and 1 process preset". - Only the printer and those two presets were deleted. - The filament inherited from was kept, and the filament inheriting from it still loaded after a restart. - A filament shared with another printer, an unrestricted filament and the account's other user presets were kept. - **Deleting the same printer on the second machine:** its profiles were already gone from the cloud. Each delete got one 404 and finished without a retry. - **Deleting a custom printer while offline:** - The deletes were retried after 1 and then 2 minutes, and the `.info` files stayed. - The app was then quit while offline, the network reconnected, and the app started again. - The deletes of the printer and its filament were sent at startup, and their `.info` files were removed. - The printer was not brought back by the startup pull. - On an earlier run, a filament deleted offline was retried after 1, 2 and 4 minutes, and the attempt after reconnecting succeeded. - **`.info` files left by older builds, at startup:** - A system preset id sent no request. - Profiles the cloud doesn't have, one of them a custom printer's, each got one 404 and finished. - An entry owned by another account was never sent. - **Deleting a filament from the Edit Filament dialog:** its delete was sent and succeeded. - **Saving another preset over a synced preset**, on `1e1f9dc2` and then `dc2400b2`: - Each save was on the Mac. It uploaded an update under the same id and sent no delete. - Windows got the new settings at its next start. - Two of the saves replaced a preset with no parent, and on the Mac its file moved out of `base` with nothing left behind. - On `1e1f9dc2`, Windows kept the old copy in `base` as well. On `dc2400b2` it moved its copy the same way the Mac did. - **Subscription polls:** every poll after the first got a 304 and logged `(unchanged)`, including the first poll after the network came back. **Not run by hand: copying a bundle's presets for a new printer.** The account has no subscribed bundles, so this is covered only by the unit test. **Not run: switching accounts.** This should be checked by hand with two accounts before merging: 1. As account A, go offline and delete a synced user preset. - Expected: the delete fails and its `.info` file stays. 2. Sign in as B and go back online. - Expected: nothing of A's is sent. 3. Sign back in as A. - Expected: the delete is sent with A's token and the `.info` is removed. <!-- > A guide for users on how to download the artifacts from this PR. --> [How to Download Pull Requests Artifacts for Testing](https://www.orcaslicer.com/wiki/how_to_download_pr_artifacts)
OrcaSlicer tests
Building, running and writing tests is documented on the wiki, under How to Test.
Two files here rather than there, because coding agents only read what is in the repository: