Repository navigation
COPY, MOVE and the time of a file in the backend contract - #36
Merged
Merged
Conversation
The contract of a backend gets new methods, as the features Copy, Move, DirMove and SetModTime of rclone: - COPY of a file and MOVE of a file, with the header Destination: the path of the destination in the same root. MOVE of a folder goes to a path that does not exist, else 412. - PATCH of a file with X-OC-Mtime sets its time. - PUT, COPY and MOVE with X-OC-Mtime give that time to the file, and the answer has X-OC-Mtime: accepted. X-OC-Mtime is the header of ownCloud: seconds after 1970, with an optional part of a second. fetch.js gives the backend the path of the destination from its location. The two locations must have the same type, query and options, else the answer is 502 and the backend gets no request: a Destination never takes a backend out of its remote. The backends: - memory and local: COPY, MOVE, PATCH and the time. Node.js sets a time to the microsecond. - s3: COPY with CopyObject, and the time in the metadata mtime, as rclone. PATCH copies the object onto itself. GET and HEAD give the time of the metadata. The list gives the time of the upload. - webdav: COPY and MOVE on the server, with MKCOL of the folders first. The time goes to the vendors of rclone with useOCMtime, and a PROPPATCH of lastmodified sets it for owncloud, nextcloud and infinitescale. The time does not go with a COPY to rclone serve webdav: that server gives it to the source. - crypt, alias, combine (in one upstream), and the folders of chunker and compress give the destination in their remote. The files of an archive or of a tiles file give 405. drive gives 405 to other methods. The commands: - copy and copyto send COPY first, with the time of the source. For 403, 405, 501 and 502, the bytes go through rfetch, with the time. A second copy skips the same files. When the list of the target gives another time than HEAD, as s3 does, HEAD gives the time. - move and moveto send MOVE first. A folder moves with one MOVE when the target does not exist, as DirMove of rclone. - touch sets the time of a file that exists with PATCH, and --timestamp works as rclone: YYMMDD, or a time of 19 characters or more. serve webdav and the Worker send COPY and MOVE to the backend first, give X-OC-Mtime to the destination, and make a PROPPATCH of lastmodified a PATCH. The shared suite tests the new methods with the features of each backend. cmd/rclone_test.js compares move with DirMove, the times of a copy, a second copy and touch with rclone.
utimes takes the seconds as a double. Node.js 22 cuts the part of a second to the microsecond, and Node.js 24 and later keep the nanoseconds of the double. The half of a microsecond that the last commit added gave 476 ns to a whole second on Node.js 24 and 26. Now the value is the double nearest to the time. When the system would give the microsecond before or after, the next double in the correct microsecond is the value. A test of 20000 random times on Node.js 22 and 26 gives each time to the correct microsecond, and a whole second with no nanoseconds.
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.
New methods in the backend contract:
COPY and MOVE of a file, with the header Destination.
MOVE of a folder to a new path. If the path exists, the answer is 412.
PATCH with X-OC-Mtime sets the time of a file.
A PUT, COPY or MOVE with X-OC-Mtime gives that time to the file, and the answer is X-OC-Mtime: accepted.
fetch.js finds the path of the destination. A destination in another remote gives 502.
The memory, local, s3, webdav, crypt and alias backends have the new methods, and the commands and serve webdav use them.
Fix: the time of a local file is correct to the microsecond on each version of Node.js.