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
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,26 @@ the local time zone, and the size and the count with `sizeField` and
`countField` of `@rfetch/lib/format`, in fields of the widths of rclone.
`cmd/lsf/rclone_test.js` compares the lines with the lines of rclone.

The other commands use the operations of `cmd/operations.js`, as the package
`operations` of rclone: `stat` gives the information of a path, `walk` gives the
files and the folders in a folder, and `copyFile`, `remove` and `mkdir` change
the files. An operation that fails throws an `OperationError` with the status of
the answer, and `failure` gives the answer of the command for it. `log` writes
the errors and the notices of rclone on the standard error, for example
`2006/01/02 15:04:05 ERROR : a.txt: sizes differ`, and `--quiet` keeps only the
errors. A command that has an output and an error, for example
`check --combined -`, gives the output in the body and the error in
`statusText`: the command line writes the body on the standard output, and the
error on the standard error.

The command line gives the exit codes of rclone: 3 for the status 404, 4 for the
status 404 with a message that ends with `object not found`, and 1 for another
status that is not 2xx.

`cmd/rclone_test.js` runs each command with rfetch and with rclone on the same
local folders, and compares the outputs, the exit codes and the files after the
command.

## Tests of a backend

Each backend must pass the shared tests of `@rfetch/lib/testing/suite`. These
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,30 @@ remote.

## Commands

The commands give the output of rclone, and its exit codes: 3 for a folder that
does not exist, 4 for a file that does not exist, and 1 for another error.

- `backend`
- `cat`
- `check`, `checksum` and `cryptcheck`: compare the files of two places, or the
files and a sum file. The backends give no hash: `check` compares the sizes,
and with `--download` the bytes.
- `config`
- `copy`
- `copy` and `copyto`: copy the files that the target does not have, or that
differ by size or by time.
- `copyurl`
- `cryptdecode`
- `delete`, `deletefile`, `purge`, `rmdir` and `rmdirs`
- `hashsum`, `md5sum` and `sha1sum`: MD5, SHA-1, SHA-256, SHA-512 and CRC-32.
rfetch reads each file to compute its hash.
- `listremotes`
- `ls`
- `lsd`
- `lsf`
- `lsjson`
- `lsl`
- `mkdir`
- `move` and `moveto`: copy, then delete each source file.
- `obscure`
- `rcat`
- `reveal`
Expand All @@ -81,6 +95,10 @@ remote.
- `serve webdav`: serve a remote over WebDAV, as `rclone serve webdav`. A client
reads and writes, unless `--read-only`. With `--user` and `--pass`, a client
must log in with them.
- `size`
- `touch`: make an empty file. The backends cannot set the time of a file yet.
- `tree`
- `version`

## Runtimes

Expand Down
19 changes: 19 additions & 0 deletions backend/crypt/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,25 @@ export async function decode(options, ...args) {
return new Response(decoded.join(""));
}

/**
* The cipher of the names of a crypt remote, for the command `cryptdecode`:
* it makes the keys one time for all the names.
*
* ```js
* import { nameCipher } from "./main.js";
* const names = await nameCipher({ password, password2 });
* names.decrypt(encryptedName);
* ```
* @param {Object} options
* @param {string} options.password The password, obscured.
* @param {string} [options.password2] The salt, obscured.
* @returns {Promise<{ encrypt: (path: string) => string, decrypt: (path: string) => string }>}
*/
export async function nameCipher(options) {
const { names } = await cipherOf(options.password, options.password2 ?? "");
return names;
}

/**
* Makes the keys from a password and a salt, as `Cipher.Key` of rclone: 32
* bytes for the data, 32 bytes for the names, and 16 bytes of tweak for the
Expand Down
9 changes: 8 additions & 1 deletion backend/union/rclone_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
* The policy `epff` of rclone takes the upstream that answers first, thus
* the tests cannot compare it. rfetch takes the first upstream in the order
* of the upstreams, as the documentation of rclone tells.
*
* rclone runs with `--disable About`: then it reads no free space, and the
* policies of space, as `epmfs`, take the first upstream, as rfetch. Else
* rclone takes the upstream with the most free space. The upstreams are on
* one disk, but other tests write on it at the same time, thus rclone can
* take `b`.
*/
import { after, describe, test } from "node:test";
import assert from "node:assert/strict";
Expand Down Expand Up @@ -85,7 +91,8 @@ describe("union and rclone", {
* @param {string} [input]
*/
function rclone(args, input) {
return spawnSync(RCLONE, ["--config", join(folder, "none.conf"), ...args], {
const config = ["--config", join(folder, "none.conf")];
return spawnSync(RCLONE, [...config, "--disable", "About", ...args], {
env: { PATH: process.env.PATH, HOME: folder },
encoding: "utf8",
input,
Expand Down
Loading
Loading