webdav: x-oc-mtime as float (#1240); closes #1239

This commit is contained in:
Josh Willox
2026-01-25 16:31:45 +00:00
committed by GitHub
parent b20d32593e
commit 296362fc84
3 changed files with 23 additions and 4 deletions
+3 -3
View File
@@ -106,14 +106,14 @@ def utime(
def utime_c( def utime_c(
log: Union["NamedLogger", Any], log: Union["NamedLogger", Any],
p: str, p: str,
ts: int, ts: float,
follow_symlinks: bool = True, follow_symlinks: bool = True,
throw: bool = False, throw: bool = False,
) -> Optional[int]: ) -> Optional[float]:
clamp = 0 clamp = 0
ov = ts ov = ts
bp = fsenc(p) bp = fsenc(p)
now = int(time.time()) now = time.time()
while True: while True:
try: try:
if SYMTIME: if SYMTIME:
+1 -1
View File
@@ -2618,7 +2618,7 @@ class HttpCli(object):
at = mt = time.time() - lifetime at = mt = time.time() - lifetime
cli_mt = self.headers.get("x-oc-mtime") cli_mt = self.headers.get("x-oc-mtime")
if cli_mt: if cli_mt:
bos.utime_c(self.log, path, int(cli_mt), False) bos.utime_c(self.log, path, float(cli_mt), False)
if nameless and "magic" in vfs.flags: if nameless and "magic" in vfs.flags:
try: try:
+19
View File
@@ -63,6 +63,20 @@ Accept-Encoding: gzip
fgsfds""" fgsfds"""
RCLONE_PUT_FLOAT = """PUT /%s HTTP/1.1
Host: 127.0.0.1:3923
User-Agent: rclone/v1.67.0
Content-Length: 6
Authorization: Basic azp1
Content-Type: application/octet-stream
Oc-Checksum: SHA1:f5e3dc3fb27af53cd0005a1184e2df06481199e8
Referer: http://127.0.0.1:3923/
X-Oc-Mtime: 1689453578.123
Accept-Encoding: gzip
fgsfds"""
# tcpdump of `rclone delete dav:/a/d1/` (it does propfind recursively and then this on each file) # tcpdump of `rclone delete dav:/a/d1/` (it does propfind recursively and then this on each file)
# (note: `rclone rmdirs dav:/a/d1/` does the same thing but just each folder after asserting they're empty) # (note: `rclone rmdirs dav:/a/d1/` does the same thing but just each folder after asserting they're empty)
RCLONE_DELETE = """DELETE /%s HTTP/1.1 RCLONE_DELETE = """DELETE /%s HTTP/1.1
@@ -201,6 +215,11 @@ class TestHttpCli(TC):
h, b = self.req(RCLONE_PUT % ("a/fa",)) h, b = self.req(RCLONE_PUT % ("a/fa",))
self.assertStart("HTTP/1.1 201 Created\r", h) self.assertStart("HTTP/1.1 201 Created\r", h)
# float x-oc-mtime should be accepted
h, b = self.req(RCLONE_PUT_FLOAT % ("a/fb",))
self.assertStart("HTTP/1.1 201 Created\r", h)
self.assertAlmostEqual(os.path.getmtime("a/fb"), 1689453578.123, places=3)
# then it does a propfind to confirm # then it does a propfind to confirm
h, b = self.req(RCLONE_PROPFIND % ("a/fa",)) h, b = self.req(RCLONE_PROPFIND % ("a/fa",))
fns = pfind2ls(b) fns = pfind2ls(b)