feat(12-02): normalize all four providers into CloudResourceAdapter contract

- GoogleDriveBackend: list_folder with full pagination, native doc size=None, get_capabilities
- OneDriveBackend: list_folder with @odata.nextLink pagination, get_capabilities
- WebDAVBackend: list_folder via PROPFIND with SSRF re-validation, get_capabilities
- NextcloudBackend: inherits CloudResourceAdapter from WebDAVBackend
- build_cloud_resource_adapter() added to factory
- 22 new contract/behavior/pagination/no-byte-download tests (51 total pass)
This commit is contained in:
curo1305
2026-06-18 22:45:09 +02:00
parent 71ba0293a5
commit ff33439f0a
5 changed files with 844 additions and 3 deletions
+22
View File
@@ -1,4 +1,7 @@
"""Factory for user-scoped cloud storage backends."""
from __future__ import annotations
from storage.cloud_base import CloudResourceAdapter
def build_cloud_backend(provider: str, credentials: dict):
@@ -31,3 +34,22 @@ def build_cloud_backend(provider: str, credentials: dict):
)
raise ValueError(f"Unknown provider: {provider}")
def build_cloud_resource_adapter(provider: str, credentials: dict) -> CloudResourceAdapter:
"""Build a CloudResourceAdapter for the given provider and credentials.
Returns a provider instance that implements the CloudResourceAdapter read-only
interface (list_folder, get_capabilities, merge_item_capabilities). All four
supported providers implement CloudResourceAdapter as a mixin alongside
their StorageBackend interface.
Raises:
ValueError: If provider is not one of the four supported cloud providers.
"""
backend = build_cloud_backend(provider, credentials)
if not isinstance(backend, CloudResourceAdapter):
raise ValueError(
f"Provider {provider!r} backend does not implement CloudResourceAdapter"
)
return backend