mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 00:52:16 -06:00
fix multiprocessing ftpd
This commit is contained in:
parent
c9b7ec72d8
commit
0b6f102436
|
@ -173,12 +173,8 @@ class FtpFs(AbstractedFS):
|
||||||
raise FilesystemError("the delete feature is disabled in server config")
|
raise FilesystemError("the delete feature is disabled in server config")
|
||||||
|
|
||||||
vp = join(self.cwd, path).lstrip("/")
|
vp = join(self.cwd, path).lstrip("/")
|
||||||
x = self.hub.broker.put(
|
|
||||||
True, "up2k.handle_rm", self.uname, self.h.remote_ip, [vp]
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
x.get()
|
self.hub.up2k.handle_rm(self.uname, self.h.remote_ip, [vp])
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise FilesystemError(str(ex))
|
raise FilesystemError(str(ex))
|
||||||
|
|
||||||
|
@ -192,9 +188,8 @@ class FtpFs(AbstractedFS):
|
||||||
|
|
||||||
svp = join(self.cwd, src).lstrip("/")
|
svp = join(self.cwd, src).lstrip("/")
|
||||||
dvp = join(self.cwd, dst).lstrip("/")
|
dvp = join(self.cwd, dst).lstrip("/")
|
||||||
x = self.hub.broker.put(True, "up2k.handle_mv", self.uname, svp, dvp)
|
|
||||||
try:
|
try:
|
||||||
x.get()
|
self.hub.up2k.handle_mv(self.uname, svp, dvp)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise FilesystemError(str(ex))
|
raise FilesystemError(str(ex))
|
||||||
|
|
||||||
|
@ -260,16 +255,18 @@ class FtpFs(AbstractedFS):
|
||||||
|
|
||||||
class FtpHandler(FTPHandler):
|
class FtpHandler(FTPHandler):
|
||||||
abstracted_fs = FtpFs
|
abstracted_fs = FtpFs
|
||||||
|
hub = None # type: SvcHub
|
||||||
|
args = None # type: argparse.Namespace
|
||||||
|
|
||||||
def __init__(self, conn, server, ioloop=None):
|
def __init__(self, conn, server, ioloop=None):
|
||||||
|
self.hub = FtpHandler.hub # type: SvcHub
|
||||||
|
self.args = FtpHandler.args # type: argparse.Namespace
|
||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
FTPHandler.__init__(self, conn, server, ioloop)
|
FTPHandler.__init__(self, conn, server, ioloop)
|
||||||
else:
|
else:
|
||||||
super(FtpHandler, self).__init__(conn, server, ioloop)
|
super(FtpHandler, self).__init__(conn, server, ioloop)
|
||||||
|
|
||||||
self.hub = None # type: SvcHub
|
|
||||||
self.args = None # type: argparse.Namespace
|
|
||||||
|
|
||||||
# abspath->vpath mapping to resolve log_transfer paths
|
# abspath->vpath mapping to resolve log_transfer paths
|
||||||
self.vfs_map = {}
|
self.vfs_map = {}
|
||||||
|
|
||||||
|
@ -282,7 +279,7 @@ class FtpHandler(FTPHandler):
|
||||||
# print("ftp_STOR: {} {} OK".format(vp, mode))
|
# print("ftp_STOR: {} {} OK".format(vp, mode))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def log_transfer(self, cmd, filename, receive, completed, elapsed, nbytes):
|
def log_transfer(self, cmd, filename, receive, completed, elapsed, bytes):
|
||||||
ap = filename.decode("utf-8", "replace")
|
ap = filename.decode("utf-8", "replace")
|
||||||
vp = self.vfs_map.pop(ap, None)
|
vp = self.vfs_map.pop(ap, None)
|
||||||
# print("xfer_end: {} => {}".format(ap, vp))
|
# print("xfer_end: {} => {}".format(ap, vp))
|
||||||
|
@ -290,9 +287,7 @@ class FtpHandler(FTPHandler):
|
||||||
vp, fn = os.path.split(vp)
|
vp, fn = os.path.split(vp)
|
||||||
vfs, rem = self.hub.asrv.vfs.get(vp, self.username, False, True)
|
vfs, rem = self.hub.asrv.vfs.get(vp, self.username, False, True)
|
||||||
vfs, rem = vfs.get_dbv(rem)
|
vfs, rem = vfs.get_dbv(rem)
|
||||||
self.hub.broker.put(
|
self.hub.up2k.hash_file(
|
||||||
False,
|
|
||||||
"up2k.hash_file",
|
|
||||||
vfs.realpath,
|
vfs.realpath,
|
||||||
vfs.flags,
|
vfs.flags,
|
||||||
rem,
|
rem,
|
||||||
|
@ -302,7 +297,7 @@ class FtpHandler(FTPHandler):
|
||||||
)
|
)
|
||||||
|
|
||||||
return FTPHandler.log_transfer(
|
return FTPHandler.log_transfer(
|
||||||
self, cmd, filename, receive, completed, elapsed, nbytes
|
self, cmd, filename, receive, completed, elapsed, bytes
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -70,12 +70,6 @@ class HttpSrv(object):
|
||||||
self.cb_ts = 0
|
self.cb_ts = 0
|
||||||
self.cb_v = 0
|
self.cb_v = 0
|
||||||
|
|
||||||
try:
|
|
||||||
x = self.broker.put(True, "thumbsrv.getcfg")
|
|
||||||
self.th_cfg = x.get()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
env = jinja2.Environment()
|
env = jinja2.Environment()
|
||||||
env.loader = jinja2.FileSystemLoader(os.path.join(E.mod, "web"))
|
env.loader = jinja2.FileSystemLoader(os.path.join(E.mod, "web"))
|
||||||
self.j2 = {
|
self.j2 = {
|
||||||
|
@ -100,6 +94,18 @@ class HttpSrv(object):
|
||||||
if self.args.log_thrs:
|
if self.args.log_thrs:
|
||||||
start_log_thrs(self.log, self.args.log_thrs, nid)
|
start_log_thrs(self.log, self.args.log_thrs, nid)
|
||||||
|
|
||||||
|
self.th_cfg = {} # type: dict[str, Any]
|
||||||
|
t = threading.Thread(target=self.post_init)
|
||||||
|
t.daemon = True
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
def post_init(self):
|
||||||
|
try:
|
||||||
|
x = self.broker.put(True, "thumbsrv.getcfg")
|
||||||
|
self.th_cfg = x.get()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def start_threads(self, n):
|
def start_threads(self, n):
|
||||||
self.tp_nthr += n
|
self.tp_nthr += n
|
||||||
if self.args.log_htp:
|
if self.args.log_htp:
|
||||||
|
|
Loading…
Reference in a new issue