mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 00:52:16 -06:00
clean-shutdown while hashing huge files
This commit is contained in:
parent
56a62db591
commit
90555a4cea
|
@ -165,7 +165,7 @@ class HttpSrv(object):
|
|||
"""listens on a shared tcp server"""
|
||||
ip, port = srv_sck.getsockname()
|
||||
fno = srv_sck.fileno()
|
||||
msg = "subscribed @ {}:{} f{}".format(ip, port, fno)
|
||||
msg = "subscribed @ {}:{} f{} p{}".format(ip, port, fno, os.getpid())
|
||||
self.log(self.name, msg)
|
||||
|
||||
def fun() -> None:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# coding: utf-8
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
import sys
|
||||
|
@ -128,7 +129,7 @@ class TcpSrv(object):
|
|||
srv.listen(self.args.nc)
|
||||
ip, port = srv.getsockname()
|
||||
fno = srv.fileno()
|
||||
msg = "listening @ {}:{} f{}".format(ip, port, fno)
|
||||
msg = "listening @ {}:{} f{} p{}".format(ip, port, fno, os.getpid())
|
||||
self.log("tcpsrv", msg)
|
||||
if self.args.q:
|
||||
print(msg)
|
||||
|
|
|
@ -209,7 +209,8 @@ class Up2k(object):
|
|||
def _unblock(self) -> None:
|
||||
if self.blocked is not None:
|
||||
self.blocked = None
|
||||
self.log("uploads are now possible", 2)
|
||||
if not self.stop:
|
||||
self.log("uploads are now possible", 2)
|
||||
|
||||
def get_state(self) -> str:
|
||||
mtpq: Union[int, str] = 0
|
||||
|
@ -822,6 +823,9 @@ class Up2k(object):
|
|||
self.log("hash: {} @ [{}]".format(repr(ex), abspath))
|
||||
continue
|
||||
|
||||
if not hashes:
|
||||
return -1
|
||||
|
||||
wark = up2k_wark_from_hashlist(self.salt, sz, hashes)
|
||||
|
||||
self.db_add(db.c, wark, rd, fn, lmod, sz, "", 0)
|
||||
|
@ -1035,6 +1039,9 @@ class Up2k(object):
|
|||
self.log("hash: {} @ [{}]".format(repr(ex), abspath))
|
||||
continue
|
||||
|
||||
if not hashes:
|
||||
return -1
|
||||
|
||||
w2 = up2k_wark_from_hashlist(self.salt, sz2, hashes)
|
||||
|
||||
if w == w2:
|
||||
|
@ -2587,6 +2594,9 @@ class Up2k(object):
|
|||
ret = []
|
||||
with open(fsenc(path), "rb", 512 * 1024) as f:
|
||||
while fsz > 0:
|
||||
if self.stop:
|
||||
return []
|
||||
|
||||
if self.pp:
|
||||
mb = int(fsz / 1024 / 1024)
|
||||
self.pp.msg = "{}{} MB, {}".format(prefix, mb, path)
|
||||
|
@ -2831,6 +2841,9 @@ class Up2k(object):
|
|||
self.log("hashing " + abspath)
|
||||
inf = bos.stat(abspath)
|
||||
hashes = self._hashlist_from_file(abspath)
|
||||
if not hashes:
|
||||
return
|
||||
|
||||
wark = up2k_wark_from_hashlist(self.salt, inf.st_size, hashes)
|
||||
with self.mutex:
|
||||
self.idx_wark(ptop, wark, rd, fn, inf.st_mtime, inf.st_size, ip, at)
|
||||
|
|
Loading…
Reference in a new issue