From 4b2b4ed52d6c188290fa907dd1f6d07d7cb43c64 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 24 Oct 2022 16:08:02 +0200 Subject: [PATCH] smb: fix file rename --- .vscode/launch.py | 2 ++ README.md | 1 + copyparty/smbd.py | 5 ++++- copyparty/util.py | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) mode change 100644 => 100755 .vscode/launch.py diff --git a/.vscode/launch.py b/.vscode/launch.py old mode 100644 new mode 100755 index 5f1319d3..16f1d284 --- a/.vscode/launch.py +++ b/.vscode/launch.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + # takes arguments from launch.json # is used by no_dbg in tasks.json # launches 10x faster than mspython debugpy diff --git a/README.md b/README.md index 4f2d8f7b..c474b321 100644 --- a/README.md +++ b/README.md @@ -760,6 +760,7 @@ and some minor issues, * listens on the first `-i` interface only (default = 0.0.0.0 = all) * login doesn't work on winxp, but anonymous access is ok -- remove all accounts from copyparty config for that to work * win10 onwards does not allow connecting anonymously / without accounts +* on windows, creating a new file through rightclick --> new --> textfile throws an error due to impacket limitations -- hit OK and F5 to get your file * python3 only * slow diff --git a/copyparty/smbd.py b/copyparty/smbd.py index 41781b6d..0ae5e813 100644 --- a/copyparty/smbd.py +++ b/copyparty/smbd.py @@ -198,7 +198,10 @@ class SMB(object): vp2 = vp2.lstrip("/") ap2 = self._v2a("rename", vp2, vp1)[1] self.hub.up2k.handle_mv(LEELOO_DALLAS, vp1, vp2) - bos.makedirs(ap2, exist_ok=True) + try: + bos.makedirs(ap2) + except: + pass def _mkdir(self, vpath: str) -> None: return bos.mkdir(self._v2a("mkdir", vpath)[1]) diff --git a/copyparty/util.py b/copyparty/util.py index 7a65f6e5..fbcbc82f 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -1923,8 +1923,8 @@ def sendfile_kern( n = os.sendfile(out_fd, in_fd, ofs, req) stuck = 0 except OSError as ex: + # client stopped reading; do another select d = time.time() - stuck - log("sendfile stuck for {:.3f} sec: {!r}".format(d, ex), "90") if d < 3600 and ex.errno == errno.EWOULDBLOCK: continue