Repository navigation
Sync with Dropbox on the desktop - #372
Merged
Merged
Conversation
A Dropbox backend for the app folder (`crates/remote/src/dropbox.rs`), as designed in #370: - Listing through `list_folder` and its cursor. - New names are uploaded with `add`, and replaces with `update` by the rev this device last read or wrote. - Writes go one at a time, since Dropbox answers 429 to writes sent together. The records of a sync go up as upload sessions, sent 16 at once, and are committed by one `finish_batch_v2` through the `batch`/`replace_all` hook, each entry keeping its own condition. - A name the listing says is gone is written with `add` again. Desktop sign-in: PKCE through a loopback on the port registered with Dropbox (52819), since Dropbox takes no other. Settings › Sync › Dropbox; another account is asked about; Stop syncing revokes the token. Tested against a fake Dropbox, and once against the real one (SHELLWING_DROPBOX_REFRESH): a vault of 21 hosts started in 6.6 s, and a second device joined and synced in 7.3 s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Dropbox takes only the redirects registered on the app, so a port another program holds stopped signing in. Ports 52820 and 52821 are now registered too, after 52819, and each is tried in turn. `localhost` is [::1] as well on macOS and Windows, and a browser may try it first. A program holding the port there alone would get the code while shellwing waited until signing in timed out. Now the port is taken on [::1] too where the machine has IPv6, so a browser coming back that way is answered. A port held on either side is passed over. When all three are taken, the reason shows beside the button. Tests: a port held on IPv6 alone is passed over, and a browser coming back over IPv6 is answered; both fail without the change. A UI scenario holds the three ports and checks the reason shows and no browser opens. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The order of the cloud pills is now Google Drive, OneDrive, iCloud (where it goes through the web), Dropbox. On a Mac, iCloud comes first and Dropbox follows OneDrive. The two Dropbox UI scenarios take port 52818 as a lock before using the registered ports. Scenarios run at once in processes of their own, and the one that holds all three ports could make the sign-in scenario find none free. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Dec 5, 2026
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.
This PR builds step 2 of the Dropbox design (#370): the backend and desktop sign-in. Dropbox is offered in Settings › Sync as the last of the clouds: Google Drive, OneDrive, iCloud (through the web), then Dropbox.
Backend (
crates/remote/src/dropbox.rs)list_folder(recursive) the first time, thenlist_folder/continuewith its cursor. Aresetcursor lists the whole folder again.files/download. The rev comes fromDropbox-API-Result, and a read is kept until the rev changes.parallel()is 16.mode: add.updatewith the rev this device last read or wrote. A 409 meansOk(false), and the file is looked up again.format.jsonusesoverwrite.addagain (the deleted-file-comes-back trap).batch()is 1000.replace_allsends upload sessions 16 at once, then onefinish_batch_v2commits them. Each entry keeps its own condition. Entries that failed for another reason are retried one by one.invalid_grantmeans signed out; 429 and 5xx wait forRetry-After;insufficient_spacesays the account is full.users/get_current_account).dropbox::revokeis called on Stop syncing.Sign-in: PKCE with
token_access_type=offline. Dropbox refuses any unregistered port, so the app has three registered:http://localhost:52819/,…:52820/and…:52821/. This addsLoopback::bind_registered, which tries them in turn. It takes each port on both 127.0.0.1 and[::1], becauselocalhostis IPv6 too on macOS and Windows and a browser may try that first. A port another program holds on either side is passed over. A wrong-state request is answered 400, and the listener keeps waiting. When all three ports are taken, the reason shows beside the button.App
[sync] dropbox = { account, account_id }.DROPBOX_ACCOUNT, so signing in to another account is asked about first.Tests
addrace, a batch with stale entries, the deleted name, a paged listing and a cursor reset, the token, another account, 429 waits, writes from several threads, revoke, and sign-in (exact redirect, stale-state page, port fallback, missing write scope).against_the_real_dropboxruns whenSHELLWING_DROPBOX_REFRESHis set. It passed against the real API: a vault of 21 hosts started in 6.6 s, and a second device joined and synced in 7.3 s.Local checks:
make lint,cargo clippy -p shellwing --features ui-tests --all-targets,i18n.py check,cargo test --workspace, and theui_tests::syncscenarios all pass. Not done: a sign-in in the real app, which needs a person to allow it in the browser.🤖 Generated with Claude Code