df
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled
This commit is contained in:
@@ -955,6 +955,39 @@ class HydrusNetwork(Store):
|
||||
debug(f"{self._log_prefix()} get_file: url={browser_url}")
|
||||
return browser_url
|
||||
|
||||
def delete_file(self, file_identifier: str, **kwargs: Any) -> bool:
|
||||
"""Delete a file from Hydrus, then clear the deletion record.
|
||||
|
||||
This is used by the delete-file cmdlet when the item belongs to a HydrusNetwork store.
|
||||
"""
|
||||
try:
|
||||
client = self._client
|
||||
if client is None:
|
||||
debug(f"{self._log_prefix()} delete_file: client unavailable")
|
||||
return False
|
||||
|
||||
file_hash = str(file_identifier or "").strip().lower()
|
||||
if len(file_hash) != 64 or not all(ch in "0123456789abcdef" for ch in file_hash):
|
||||
debug(f"{self._log_prefix()} delete_file: invalid file hash '{file_identifier}'")
|
||||
return False
|
||||
|
||||
reason = kwargs.get("reason")
|
||||
reason_text = str(reason).strip() if isinstance(reason, str) and reason.strip() else None
|
||||
|
||||
# 1) Delete file
|
||||
client.delete_files([file_hash], reason=reason_text)
|
||||
|
||||
# 2) Clear deletion record (best-effort)
|
||||
try:
|
||||
client.clear_file_deletion_record([file_hash])
|
||||
except Exception as exc:
|
||||
debug(f"{self._log_prefix()} delete_file: clear_file_deletion_record failed: {exc}")
|
||||
|
||||
return True
|
||||
except Exception as exc:
|
||||
debug(f"{self._log_prefix()} delete_file failed: {exc}")
|
||||
return False
|
||||
|
||||
def get_metadata(self, file_hash: str, **kwargs: Any) -> Optional[Dict[str, Any]]:
|
||||
"""Get metadata for a file from Hydrus by hash.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user