feat(storage): add delete_href method to remove files and clean up empty directories
Build and Push Reader API Image / docker (push) Successful in 26s
Build and Push Reader API Image / docker (push) Successful in 26s
chore(docker): remove MongoDB service and related configurations from local setup feat(migrations): create ChapterMeta table and add search_name, size_bytes, mtime_epoch, lastScannedAt, review_status, and review_payload columns to SourceAsset chore(dependencies): remove motor and pymongo from project dependencies
This commit is contained in:
+3
-2
@@ -8,7 +8,6 @@ class Settings(BaseSettings):
|
||||
app_env: str = "development"
|
||||
|
||||
database_url: str
|
||||
mongodb_uri: str = ""
|
||||
|
||||
google_client_id: str = ""
|
||||
nextauth_secret: str = ""
|
||||
@@ -22,13 +21,15 @@ class Settings(BaseSettings):
|
||||
r2_public_base_url: str = ""
|
||||
nas_content_root: str = "./data/content"
|
||||
epub_source_root: str = "./data/epub-source"
|
||||
chapter_content_mode: str = "nas_first" # nas_first | mongo_first
|
||||
chapter_content_mode: str = "nas_first"
|
||||
auto_schema_bootstrap: str = "false"
|
||||
|
||||
deepseek_key: str = ""
|
||||
deepseek_model: str = "deepseek-chat"
|
||||
openrouter_key: str = ""
|
||||
openrouter_paused: str = "true"
|
||||
import_scan_interval_minutes: int = 30
|
||||
import_scan_limit: int = 2000
|
||||
|
||||
@property
|
||||
def google_client_id_list(self) -> list[str]:
|
||||
|
||||
+3220
-138
File diff suppressed because it is too large
Load Diff
@@ -29,5 +29,19 @@ class NasContentStorage:
|
||||
digest = hashlib.sha256(content.encode("utf-8")).hexdigest()
|
||||
return {"href": href, "sha256": digest, "size": len(content.encode("utf-8"))}
|
||||
|
||||
def delete_href(self, href: str) -> bool:
|
||||
path = self._resolve(href)
|
||||
if not path.exists() or not path.is_file():
|
||||
return False
|
||||
path.unlink(missing_ok=True)
|
||||
parent = path.parent
|
||||
while parent != self.root:
|
||||
try:
|
||||
parent.rmdir()
|
||||
except OSError:
|
||||
break
|
||||
parent = parent.parent
|
||||
return True
|
||||
|
||||
|
||||
storage = NasContentStorage(settings.nas_content_root)
|
||||
|
||||
Reference in New Issue
Block a user