From 5ac2c20959a831c6c320675d4774ad6f2ea117dc Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 20 Mar 2023 21:17:53 +0000 Subject: [PATCH] basic support for rclone sync --- copyparty/__main__.py | 2 +- copyparty/httpcli.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 81b2f255..ba38c271 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -758,7 +758,7 @@ def add_ftp(ap): def add_webdav(ap): ap2 = ap.add_argument_group('WebDAV options') - ap2.add_argument("--daw", action="store_true", help="enable full write support. \033[1;31mWARNING:\033[0m This has side-effects -- PUT-operations will now \033[1;31mOVERWRITE\033[0m existing files, rather than inventing new filenames to avoid loss of data. You might want to instead set this as a volflag where needed. By not setting this flag, uploaded files can get written to a filename which the client does not expect (which might be okay, depending on client)") + ap2.add_argument("--daw", action="store_true", help="enable full write support, even if client may not be webdav. \033[1;31mWARNING:\033[0m This has side-effects -- PUT-operations will now \033[1;31mOVERWRITE\033[0m existing files, rather than inventing new filenames to avoid loss of data. You might want to instead set this as a volflag where needed. By not setting this flag, uploaded files can get written to a filename which the client does not expect (which might be okay, depending on client)") ap2.add_argument("--dav-inf", action="store_true", help="allow depth:infinite requests (recursive file listing); extremely server-heavy but required for spec compliance -- luckily few clients rely on this") ap2.add_argument("--dav-mac", action="store_true", help="disable apple-garbage filter -- allow macos to create junk files (._* and .DS_Store, .Spotlight-*, .fseventsd, .Trashes, .AppleDouble, __MACOS)") diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 75b1ba54..9a5f5491 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -1429,9 +1429,9 @@ class HttpCli(object): self.log(t, 1) raise Pebkac(403, t) - if is_put and not (self.args.no_dav or self.args.nw): + if is_put and not (self.args.no_dav or self.args.nw) and bos.path.exists(path): # allow overwrite if... - # * volflag 'daw' is set + # * volflag 'daw' is set, or client is definitely webdav # * and account has delete-access # or... # * file exists, is empty, sufficiently new @@ -1441,9 +1441,11 @@ class HttpCli(object): if self.args.dotpart: tnam = "." + tnam - if (vfs.flags.get("daw") and self.can_delete) or ( + if ( + self.can_delete + and (vfs.flags.get("daw") or "x-oc-mtime" in self.headers) + ) or ( not bos.path.exists(os.path.join(fdir, tnam)) - and bos.path.exists(path) and not bos.path.getsize(path) and bos.path.getmtime(path) >= time.time() - self.args.blank_wt ):