depot/patches/base/s3ql/s3c-accurate-length.patch

27 lines
762 B
Diff

commit 1edbbcf08d5701ea38f13fca7491418318aebca9
Author: Max <max@privatevoid.net>
Date: Fri Jun 7 23:31:08 2024 +0200
accurate length
diff --git a/src/s3ql/backends/s3c.py b/src/s3ql/backends/s3c.py
index 2995ca4f..3c3c79ab 100644
--- a/src/s3ql/backends/s3c.py
+++ b/src/s3ql/backends/s3c.py
@@ -387,9 +387,13 @@ class Backend(AbstractBackend):
'''
off = fh.tell()
+ fh.seek(0, os.SEEK_END)
+ actual_len = fh.tell() - off
+ fh.seek(off, os.SEEK_SET)
if len_ is None:
- fh.seek(0, os.SEEK_END)
- len_ = fh.tell()
+ len_ = actual_len
+ else:
+ len_ = min(len_, actual_len)
return self._write_fh(key, fh, off, len_, metadata or {})
@retry