dfdf
This commit is contained in:
@@ -50,6 +50,51 @@ class Store(ABC):
|
||||
def add_url(self, file_identifier: str, url: List[str], **kwargs: Any) -> bool:
|
||||
raise NotImplementedError
|
||||
|
||||
def add_url_bulk(self, items: List[Tuple[str, List[str]]], **kwargs: Any) -> bool:
|
||||
"""Optional bulk url association.
|
||||
|
||||
Backends may override this to batch writes (single transaction / request).
|
||||
Default behavior is to call add_url() per file.
|
||||
"""
|
||||
changed_any = False
|
||||
for file_identifier, urls in (items or []):
|
||||
try:
|
||||
ok = self.add_url(file_identifier, urls, **kwargs)
|
||||
changed_any = changed_any or bool(ok)
|
||||
except Exception:
|
||||
continue
|
||||
return changed_any
|
||||
|
||||
def delete_url_bulk(self, items: List[Tuple[str, List[str]]], **kwargs: Any) -> bool:
|
||||
"""Optional bulk url deletion.
|
||||
|
||||
Backends may override this to batch writes (single transaction / request).
|
||||
Default behavior is to call delete_url() per file.
|
||||
"""
|
||||
changed_any = False
|
||||
for file_identifier, urls in (items or []):
|
||||
try:
|
||||
ok = self.delete_url(file_identifier, urls, **kwargs)
|
||||
changed_any = changed_any or bool(ok)
|
||||
except Exception:
|
||||
continue
|
||||
return changed_any
|
||||
|
||||
def set_note_bulk(self, items: List[Tuple[str, str, str]], **kwargs: Any) -> bool:
|
||||
"""Optional bulk note set.
|
||||
|
||||
Backends may override this to batch writes (single transaction / request).
|
||||
Default behavior is to call set_note() per file.
|
||||
"""
|
||||
changed_any = False
|
||||
for file_identifier, name, text in (items or []):
|
||||
try:
|
||||
ok = self.set_note(file_identifier, name, text, **kwargs)
|
||||
changed_any = changed_any or bool(ok)
|
||||
except Exception:
|
||||
continue
|
||||
return changed_any
|
||||
|
||||
@abstractmethod
|
||||
def delete_url(self, file_identifier: str, url: List[str], **kwargs: Any) -> bool:
|
||||
raise NotImplementedError
|
||||
|
||||
Reference in New Issue
Block a user