diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index dd6ba832..a68e2831 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -4246,6 +4246,7 @@ class HttpCli(object): self.log(t % (data_end / M, lower / M, upper / M), 6) with self.u2mutex: if data_end > self.u2fh.aps.get(ap_data, data_end): + fhs: Optional[set[typing.BinaryIO]] = None try: fhs = self.u2fh.cache[ap_data].all_fhs for fh in fhs: @@ -4253,7 +4254,11 @@ class HttpCli(object): self.u2fh.aps[ap_data] = data_end self.log("pipe: flushed %d up2k-FDs" % (len(fhs),)) except Exception as ex: - self.log("pipe: u2fh flush failed: %r" % (ex,)) + if fhs is None: + err = "file is not being written to right now" + else: + err = repr(ex) + self.log("pipe: u2fh flush failed: " + err) if lower >= data_end: if data_end: