Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches: [main]
pull_request:
workflow_call:

permissions:
contents: read
Expand All @@ -24,13 +25,26 @@ jobs:
rustup toolchain install stable --profile minimal --component rustfmt --component clippy
rustup default stable
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
# The tests that talk to a real `rclone rcd` skip themselves without it:
# install the current release so they run (the distribution's is too old).
- name: Install rclone
run: curl -fsSL https://rclone.org/install.sh | sudo bash
- run: cargo fmt --check
- run: cargo clippy --all-targets -- -D warnings
- run: cargo test
- run: cargo clippy --locked --all-targets -- -D warnings
- name: Install minimum supported rclone
run: bash scripts/install-test-rclone.sh 1.68.0 "$RUNNER_TEMP/rclone-minimum"
- name: Test with rclone 1.68.0
run: |
export PATH="$RUNNER_TEMP/rclone-minimum:$PATH"
RATCLONE_TEST_RCLONE_VERSION=1.68.0 cargo test --locked
- name: Install current rclone release
run: bash scripts/install-test-rclone.sh latest "$RUNNER_TEMP/rclone-current"
- name: Test with current rclone
run: |
export PATH="$RUNNER_TEMP/rclone-current:$PATH"
RATCLONE_TEST_RCLONE_VERSION=$(cat "$RUNNER_TEMP/rclone-current/version") cargo test --locked
- name: Install minimum rclone for cancellable browser login
run: bash scripts/install-test-rclone.sh 1.75.0 "$RUNNER_TEMP/rclone-oauth-minimum"
- name: Test browser login cancellation with rclone 1.75.0
run: |
export PATH="$RUNNER_TEMP/rclone-oauth-minimum:$PATH"
RATCLONE_TEST_RCLONE_VERSION=1.75.0 cargo test --locked --test rc_backend local_login_requires_cancellable_rclone_or_frees_port

# Licences, advisories, banned crates and sources (deny.toml).
supply-chain:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ env:
CARGO_GENERATE_RPM_VERSION: 0.21.1

jobs:
# A local reusable workflow checks out this tag/dispatch commit. Publication
# cannot proceed until fmt, clippy and the full suite pass against both
# the minimum supported and current rclone, along with the other CI gates.
validate:
uses: ./.github/workflows/ci.yml

# A static (musl) binary per architecture, each built natively, so it runs
# on any Linux distribution whatever its glibc.
build:
needs: validate
strategy:
matrix:
include:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ All notable changes to this project are documented here. The format follows

## [Unreleased]

### Fixed

- Keep background transfers running with rclone 1.68.0, whose `job/list`
response does not include the newer `runningIds` field.
- Offer authorization-token login on rclone versions older than 1.75.0,
which cannot cancel an in-app browser login cleanly.

## [0.1.1] - 2026-11-15

### Added
Expand Down
25 changes: 25 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,31 @@ You need Rust 1.88 or newer. rclone v1.68.0 or newer is only needed to try
the real backend and for the tests that talk to `rclone rcd`; without it
those tests skip themselves.

CI and releases require the real integration suite against both rclone 1.68.0
and the current official release, plus a focused browser-login cancellation
test on rclone 1.75.0 (the minimum for that feature). The existing
`fmt, clippy, test` check name is unchanged. To reproduce a run without
replacing your installed rclone:

```sh
test_dir=$(mktemp -d)
bash scripts/install-test-rclone.sh 1.68.0 "$test_dir" # or latest
PATH="$test_dir:$PATH" RATCLONE_TEST_RCLONE_VERSION=$(cat "$test_dir/version") cargo test --locked
rm -rf "$test_dir"
```

The installer verifies the archive against the official `SHA256SUMS` and checks
the binary's version. Setting `RATCLONE_TEST_RCLONE_VERSION` makes a missing or
different rclone fail the run; the OAuth test also fails if its localhost port
is unavailable. Tests use temporary rclone configurations and local files,
without your cloud credentials or accounts. These checks cover the rc API and
local backend; provider-specific behavior still depends on rclone and the provider.
Test daemons run with a disposable HOME and a cleared environment, so
environment-defined remotes and provider credentials cannot override fixtures.
The minimum-version suite verifies that older rclone rejects browser login
before starting a listener and offers token authorization instead. The
1.75.0 and current-version checks exercise real listener startup and cancellation.

## Before you open a pull request

Run the same checks as CI:
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ and Ubuntu ship rclone 1.60, which is too old: install the current one from
[rclone.org](https://rclone.org/install/) with
`sudo -v ; curl https://rclone.org/install.sh | sudo bash`.

Browser login inside the app requires **rclone v1.75.0 or newer** so it can
be cancelled cleanly. Older supported versions automatically offer the
authorization-token flow instead; existing accounts work as usual.

Download the file for your system from the
[latest release](https://github.com/SyscallBrain/ratclone/releases/latest).
x86_64 packages are named `amd64` or `x86_64`, and aarch64 packages `arm64`
Expand Down Expand Up @@ -127,7 +131,8 @@ ratclone --rclone ~/bin/rclone
## How it works

ratclone starts its own `rclone rcd` on a private unix socket and talks to it
through the rc API; it never listens on a network port. Copies and moves are
through the rc API, which is only available through that socket. Browser logins
may temporarily open a localhost port for OAuth. Copies and moves are
rclone jobs, so they outlive the app: a small helper records how each one ends
and stops the rcd once they are done. See
[How it works](https://syscallbrain.github.io/ratclone/how-it-works.html).
Expand Down
5 changes: 4 additions & 1 deletion book/src/accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ only sent if you type a new one. Only the fields you change are sent.

Google Drive, Dropbox, OneDrive and other accounts log in through a browser.

- **On your own computer**, the browser opens and the app waits for you.
- **On your own computer with rclone 1.75 or newer**, the browser opens and
the app waits for you. Older versions cannot cancel this login reliably,
so the app automatically offers the authorization-token flow below. You
can run the displayed command in another terminal on the same computer.
- **Over SSH** there is no browser, so the app shows the command to run on a
machine that has one, such as `rclone authorize "dropbox"`. `y` copies it
(through OSC 52, so it works over SSH too), and you paste the result back.
Expand Down
5 changes: 3 additions & 2 deletions book/src/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
ratclone starts its own `rclone rcd`, rclone's remote-control server, on a
private unix socket (`$XDG_RUNTIME_DIR/ratclone/rc.sock`, in a directory only
you can open) and talks to it through the
[rc API](https://rclone.org/rc/). It never listens on a network port, and
never builds shell commands.
[rc API](https://rclone.org/rc/), which is only available through that socket.
Browser logins may temporarily open a localhost port for OAuth. ratclone never
builds shell commands.

Listing, renaming, deleting and account changes are rc calls. Copies and moves
are rclone *jobs*, so they keep going while you browse.
Expand Down
2 changes: 2 additions & 0 deletions book/src/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ratclone runs on Linux, on x86_64 and aarch64. It needs:

- **rclone v1.68.0 or newer.** ratclone checks the version when it starts and
says so if it is older.
Browser login inside the app needs **v1.75.0 or newer**; older supported
versions use the [authorization-token flow](accounts.md#browser-logins).
- A terminal with truecolor and a [Nerd Font](https://www.nerdfonts.com) for
the icons. Without one, set `icons = "ascii"` in the
[configuration](configuration.md) or in the settings (`,`).
Expand Down
3 changes: 3 additions & 0 deletions docs/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Release checklist

1. The gates are green: `cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test`.
The Release workflow also runs CI for the exact tag/manual-run commit and
blocks release builds on it, including the real integration suite with
rclone 1.68.0 and the current official release (see `CONTRIBUTING.md`).
2. `CHANGELOG.md` has the release section `## [X.Y.Z] - YYYY-MM-DD`; the
Release workflow uses it as the release notes and fails without it.
3. The new version is in `Cargo.toml` (and `Cargo.lock`), in
Expand Down
40 changes: 40 additions & 0 deletions scripts/install-test-rclone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Install an official, checksum-verified rclone in a disposable test directory.
# Usage: scripts/install-test-rclone.sh 1.68.0|latest DESTINATION
set -euo pipefail
version=${1:?usage: install-test-rclone.sh VERSION DESTINATION}
destination=${2:?usage: install-test-rclone.sh VERSION DESTINATION}
if [ "$version" = latest ]; then
version=$(curl --fail --silent --show-error https://downloads.rclone.org/version.txt)
version=${version#rclone v}
fi
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "invalid rclone version: $version" >&2; exit 1; }
case $(uname -m) in
x86_64) arch=amd64 ;;
aarch64) arch=arm64 ;;
*) echo 'unsupported test host architecture' >&2; exit 1 ;;
esac
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
archive="rclone-v$version-linux-$arch.zip"
url="https://downloads.rclone.org/v$version"
curl --fail --silent --show-error -o "$work/$archive" "$url/$archive"
curl --fail --silent --show-error -o "$work/SHA256SUMS" "$url/SHA256SUMS"
# SHA256SUMS is a clear-signed document: select exactly this archive's entry.
awk -v file="$archive" '$2 == file { print; count++ } END { if (count != 1) exit 1 }' \
"$work/SHA256SUMS" > "$work/checksum"
(cd "$work" && sha256sum --check --strict checksum)
mkdir -p "$destination"
python3 - "$work/$archive" "rclone-v$version-linux-$arch/rclone" "$destination/rclone" <<'PY'
import pathlib
import sys
import zipfile

with zipfile.ZipFile(sys.argv[1]) as archive:
pathlib.Path(sys.argv[3]).write_bytes(archive.read(sys.argv[2]))
PY
chmod 755 "$destination/rclone"
actual=$("$destination/rclone" version)
[[ "${actual%%$'\n'*}" = "rclone v$version" ]] || { echo "unexpected rclone version: $actual" >&2; exit 1; }
printf '%s\n' "$version" > "$destination/version"
printf '%s\n' "$actual"
8 changes: 8 additions & 0 deletions src/app/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,14 @@ impl App {
let Some(w) = self.wizard() else { return };
match (&mut w.step, result) {
(Step::WaitingBrowser { jobid, .. }, Ok(id)) => *jobid = Some(id),
(Step::WaitingBrowser { .. }, Err(BackendError::LocalOAuthUnsupported)) => {
let Some(state) = w.local_state.clone() else {
return self.wizard_failed(BackendError::LocalOAuthUnsupported);
};
w.local_flipped = !w.over_ssh;
w.auto_note = Some("Browser login needs rclone 1.75+: paste an authorization token".into());
self.answer_local(state, false);
}
(_, Ok(id)) => self.stop_job_quietly(id),
(_, Err(e)) => self.wizard_failed(e),
}
Expand Down
2 changes: 2 additions & 0 deletions src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ pub enum BackendError {
Rclone(String),
#[error("lost connection to rclone")]
Disconnected,
#[error("browser login requires rclone 1.75 or newer; paste an authorization token instead")]
LocalOAuthUnsupported,
#[error("{0}")]
Other(String),
}
Expand Down
10 changes: 9 additions & 1 deletion src/backend/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::{
};
use crate::location::{Location, Remote};
use crate::rc::types::{
RcAbout, RcConfigOut, RcJobId, RcJobStatus, RcList, RcListItem, RcOption, RcProviders, RcStats,
RcAbout, RcConfigOut, RcJobId, RcJobStatus, RcList, RcListItem, RcOption, RcProviders, RcStats, RcVersion,
};
use crate::rc::{RcError, UnixRc};
use crate::transfer::spec::{FileProgress, TransferKind, TransferProgress, TransferSpec, aggregate};
Expand Down Expand Up @@ -591,6 +591,14 @@ impl Backend for RcBackend {
answer: &str,
obscure: bool,
) -> Result<u64, BackendError> {
// Before 1.75 the OAuth callback wait ignores job cancellation, leaving
// the job and localhost listener alive. Use the token-paste flow instead.
if answer == "true" {
let version: RcVersion = self.rc.call_typed("core/version", json!({})).await?;
if version.decomposed < [1, 75, 0] {
return Err(BackendError::LocalOAuthUnsupported);
}
}
let mut body = continue_body(name, state, answer, obscure);
body["_async"] = json!(true);
let id: RcJobId = self.rc.call_typed("config/update", body).await?;
Expand Down
38 changes: 36 additions & 2 deletions src/reaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,16 @@ pub async fn record_outcomes(backend: &dyn Backend, path: &Path) {
#[derive(serde::Deserialize)]
struct JobList {
#[serde(rename = "runningIds", default)]
running: Vec<u64>,
running: Option<Vec<u64>>,
jobids: Vec<u64>,
}

impl JobList {
fn candidates(self) -> Vec<u64> {
// Older supported rclones return only jobids. Check their status below
// instead of treating a missing runningIds field as an idle daemon.
self.running.unwrap_or(self.jobids)
}
}

#[derive(serde::Deserialize)]
Expand All @@ -109,7 +118,7 @@ struct Mounts {
/// Any app transfer still running, or any mount active?
async fn busy(rc: &UnixRc) -> Result<bool, RcError> {
let jobs: JobList = rc.call_typed("job/list", json!({})).await?;
for id in jobs.running {
for id in jobs.candidates() {
if let Ok(s) = rc
.call_typed::<RcJobStatus>("job/status", json!({ "jobid": id }))
.await
Expand All @@ -122,3 +131,28 @@ async fn busy(rc: &UnixRc) -> Result<bool, RcError> {
let mounts: Mounts = rc.call_typed("mount/listmounts", json!({})).await?;
Ok(!mounts.mount_points.is_empty())
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn legacy_job_list_keeps_candidates_for_status_checks() {
// rclone 1.68 returns jobids but has no runningIds/finishedIds fields.
let jobs: JobList = serde_json::from_value(json!({
"executeId": "legacy", "jobids": [1, 2, 3]
}))
.unwrap();
assert_eq!(jobs.candidates(), vec![1, 2, 3]);
}

#[test]
fn current_job_list_limits_status_checks_to_running_jobs() {
let jobs: JobList = serde_json::from_value(json!({
"executeId": "current", "jobids": [1, 2, 3],
"finishedIds": [1, 3], "runningIds": [2]
}))
.unwrap();
assert_eq!(jobs.candidates(), vec![2]);
}
}
22 changes: 22 additions & 0 deletions tests/app_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,28 @@ async fn dropbox_local_waits_then_done() {
assert_eq!(message(&app).0, "Account d3 added");
}

#[tokio::test]
async fn older_rclone_falls_back_to_token_without_losing_account() {
let (_d, f, mut app) = sidebar_app().await;
start_add(&mut app, "dropbox", "oldcli").await;
f.fail_next("config_continue_job", BackendError::LocalOAuthUnsupported);
press(&mut app, "<C-s>");
app.settle().await;
assert_eq!(step_name(&app), "token");
assert!(wizard(&app).auto_note.as_deref().unwrap().contains("1.75"));
assert!(f.config_of("oldcli").is_some(), "unfinished account is kept");

// Trying the browser again must still offer the usable token flow.
f.fail_next("config_continue_job", BackendError::LocalOAuthUnsupported);
press(&mut app, "L");
app.settle().await;
assert_eq!(step_name(&app), "token");
press(&mut app, "{\"x\":1}<CR>");
app.settle().await;
assert!(app.overlay.is_none());
assert!(f.config_of("oldcli").unwrap().contains_key("token"));
}

#[tokio::test]
async fn esc_during_browser_wait_stops_and_deletes() {
let (_d, f, mut app) = sidebar_app().await;
Expand Down
Loading
Loading