Skip to content

COPY, MOVE and the time of a file in the backend contract - #35

Merged
sntran merged 3 commits into
mainfrom
feat/commands
Oct 20, 2026
Merged

sntran merged 3 commits into
mainfrom
feat/commands

Conversation

@sntran

@sntran sntran commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Add mkdir, delete, deletefile, purge, rmdir and rmdirs.
Add copy, copyto, move and moveto, with the flags of rclone, for example --size-only, --ignore-existing and --dry-run.
Add size, tree, touch, listremotes, version and cryptdecode.
Add md5sum, sha1sum and hashsum, and check, checksum and cryptcheck.
Each command has the output, the log and the exit codes of rclone.

New commands, with the output, the log and the exit codes of rclone:

- mkdir, delete (with --rmdirs), deletefile, purge, rmdir and rmdirs
  (with --leave-root).
- copy and copyto, move and moveto: a file goes when the target has no
  file with its name, or another size, or another time in the precision
  of the two remotes. The flags --size-only, --ignore-times,
  --ignore-existing, --create-empty-src-dirs, --delete-empty-src-dirs,
  --transfers and --dry-run work. A move is a copy, then the delete of
  each source file.
- size (with --json), tree (with the flags of the tree of rclone, and its
  quirks: no names with "." at the start, and no count of the folders
  with no file), touch, listremotes (with --long and --json), version
  and cryptdecode (with --reverse).
- md5sum, sha1sum and hashsum: MD5, SHA-1, SHA-256, SHA-512 and CRC-32,
  with --base64, --output-file and --checkfile. The backends give no
  hash: thus rfetch reads each file, as --download of rclone.
- check, checksum and cryptcheck: the lists of --combined, --match,
  --differ, --missing-on-src, --missing-on-dst and --error. check
  compares the sizes, as rclone with no common hash, and the bytes with
  --download.

copy now has the semantics of rclone: the contents of a source folder,
or a source file, go in the target folder. The old copy of one file to
a name is copyto.

The backends cannot set the time of a file yet: thus touch of a file
that exists gives the error of rclone, and a second copy sends the files
again, unless --size-only.

The shared code is in cmd/operations.js: stat, walk, copyFile, remove,
mkdir, the log on the standard error, and OperationError. lsjson gives
its walk to the other commands with listItems. A command with an output
and an error gives the error in statusText. The command line gives the
exit code 4 for "object not found".

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.
The name tests put a file with no extension. rclone serve webdav guesses
the type of such a file from its bytes. When the 64 random bytes have no
control byte, the type is text/plain, and the test fails. This occurs
for about 1 file in 1250, thus CI failed on some runs.

Now the content is the bytes 0 to 63. They are not text, and they are
not the start of a known type of file: the type is
application/octet-stream each time.
With the policy epmfs, the default create policy, rclone takes the
upstream with the most free space. The upstreams of the tests are on one
disk. rclone reads the free space of a, then of b. When another test
deletes a file between the two reads, b has more free space, and rclone
takes b. rfetch reads no free space and takes a, thus CI failed on some
runs.

Now rclone runs with --disable About. Then it reads no free space, and
the policies of space take the first upstream, as rfetch. With b on a
disk with more free space, the old tests fail each time, and the new
tests pass.
@sntran
sntran merged commit ead128b into main Oct 20, 2026
11 checks passed
@sntran
sntran deleted the feat/commands branch October 20, 2026 00:23
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.

1 participant