mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
29 lines
752 B
Python
29 lines
752 B
Python
# coding: utf-8
|
|
from __future__ import print_function, unicode_literals
|
|
|
|
import time
|
|
import tempfile
|
|
from datetime import datetime
|
|
|
|
from .bos import bos
|
|
|
|
|
|
def errdesc(errors):
|
|
report = ["copyparty failed to add the following files to the archive:", ""]
|
|
|
|
for fn, err in errors:
|
|
report.extend([" file: {}".format(fn), "error: {}".format(err), ""])
|
|
|
|
with tempfile.NamedTemporaryFile(prefix="copyparty-", delete=False) as tf:
|
|
tf_path = tf.name
|
|
tf.write("\r\n".join(report).encode("utf-8", "replace"))
|
|
|
|
dt = datetime.utcnow().strftime("%Y-%m%d-%H%M%S")
|
|
|
|
bos.chmod(tf_path, 0o444)
|
|
return {
|
|
"vp": "archive-errors-{}.txt".format(dt),
|
|
"ap": tf_path,
|
|
"st": bos.stat(tf_path),
|
|
}, report
|