v1.9.4: S3 optimizations — skip redundant health checks, folder drag-and-drop

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
chrome-storm-c442
2026-03-03 07:59:26 -05:00
parent bc2a3bc6b5
commit 61461767fd
4 changed files with 44 additions and 16 deletions

View File

@@ -74,6 +74,7 @@ class S3Client:
self._use_ssl = server.get("use_ssl", True)
self._client = None
self._transfer_config = None
self._last_ok: float = 0 # timestamp of last successful operation
# -- lifecycle --------------------------------------------------------
@@ -101,6 +102,7 @@ class S3Client:
self._transfer_config = _get_transfer_config()
# Test connection
self._client.list_buckets()
self._last_ok = time.time()
log.info("S3 connected %s", self._endpoint)
return True
except Exception as exc:
@@ -115,11 +117,16 @@ class S3Client:
return self.connect()
def _ensure_connected(self) -> bool:
"""Check connection, reconnect if needed."""
"""Check connection, reconnect if needed.
Skips health-check if last success was <30s ago (avoids redundant RTTs).
"""
if self._client is None:
return self._reconnect()
if time.time() - self._last_ok < 30:
return True
try:
self._client.list_buckets()
self._last_ok = time.time()
return True
except Exception:
return self._reconnect()
@@ -145,6 +152,7 @@ class S3Client:
return []
try:
resp = self._client.list_buckets()
self._last_ok = time.time()
return resp.get("Buckets", [])
except Exception as exc:
log.error("S3 list_buckets failed: %s", exc)
@@ -179,6 +187,7 @@ class S3Client:
objects.append(obj)
for cp in page.get("CommonPrefixes", []):
prefixes.append(cp["Prefix"])
self._last_ok = time.time()
return objects, prefixes
except Exception as exc:
log.error("S3 list_objects failed: %s", exc)