Source code for cadrumo.application.bucket_maintenance._deletion_paths
"""Deletion-path validation for the bucket-maintenance service.Used by: :class:`~application.bucket_maintenance.service.BucketMaintenanceService`to resolve the deletion paths of a real, non-link bucket root before anymanifest read or destructive assessment.The check runs before manifest reads so a symlink or Windows junctioncannot redirect assessment into storage outside the configured bucketdirectory."""from__future__importannotationsfrompathlibimportPathfrom...core.link_safetyimportis_link_likefrom..user_profile.custody_portsimportProfileBucketStoragePathsPort,ProfileBucketStoragePort
[docs]defvalidated_bucket_deletion_paths(*,root:Path,bucket_id:str,storage:ProfileBucketStoragePort,)->ProfileBucketStoragePathsPort:"""Return deletion paths only for a real, non-link bucket root."""try:paths=storage.resolve(root,bucket_id)exceptValueErrorasexc:# Persistence owns the layout validator and its concrete exception# hierarchy. The maintenance policy only exposes a neutral refusal at# this boundary, so callers cannot depend on adapter error types or# messages.raiseValueError(f"bucket deletion path resolution refused for bucket {bucket_id!r}")fromexcifis_link_like(paths.bucket_dir):raiseValueError(f"bucket deletion refuses linked bucket root: {paths.bucket_dir}")ifnotpaths.bucket_dir.is_dir():raiseFileNotFoundError(paths.bucket_dir)returnpaths