fix: ready for merge with int

This commit is contained in:
Ida Dittrich 2026-02-26 16:17:15 +01:00
parent 15fe598073
commit 1e4047caf1
2 changed files with 6 additions and 22 deletions

View file

@ -1206,20 +1206,14 @@ class ComponentObjects:
return False return False
def getFileData(self, fileId: str) -> Optional[bytes]: def getFileData(self, fileId: str) -> Optional[bytes]:
"""Returns the binary data of a file if user has access. """Returns the binary data of a file if user has access."""
# Check file access
File access is user-scoped (same as routeDataFiles): getFile() verifies the user
owns the FileItem via _createdBy. Once ownership is confirmed, we read FileData
directly to ensure the uploader can always access their file content.
"""
# Check file access (user-scoped via _createdBy - same logic as routeDataFiles)
file = self.getFile(fileId) file = self.getFile(fileId)
if not file: if not file:
logger.warning(f"No access to file ID {fileId}") logger.warning(f"No access to file ID {fileId}")
return None return None
# User owns the file - read FileData directly (bypass RBAC for owned files) fileDataEntries = getRecordsetWithRBAC(self.db, FileData, self.currentUser, recordFilter={"id": fileId}, mandateId=self.mandateId)
fileDataEntries = self.db.getRecordset(FileData, recordFilter={"id": fileId})
if not fileDataEntries: if not fileDataEntries:
logger.warning(f"No data found for file ID {fileId}") logger.warning(f"No data found for file ID {fileId}")
return None return None

View file

@ -36,15 +36,6 @@ def discoverFeatureContainers() -> List[str]:
return sorted(containers) return sorted(containers)
def _router_load_order_key(filepath: str) -> tuple:
"""
Sort key for router loading. Longer/lexicographically later prefixes first
so that more specific routes (e.g. /api/chatplayground) register before generic ones.
"""
featureDir = os.path.basename(os.path.dirname(filepath))
return (-len(featureDir), featureDir)
def loadFeatureRouters(app: FastAPI) -> Dict[str, Any]: def loadFeatureRouters(app: FastAPI) -> Dict[str, Any]:
""" """
Dynamically load and register routers from all discovered feature containers. Dynamically load and register routers from all discovered feature containers.
@ -57,9 +48,8 @@ def loadFeatureRouters(app: FastAPI) -> Dict[str, Any]:
""" """
results = {} results = {}
pattern = os.path.join(FEATURES_DIR, "*", "routeFeature*.py") pattern = os.path.join(FEATURES_DIR, "*", "routeFeature*.py")
filepaths = sorted(glob.glob(pattern), key=_router_load_order_key)
for filepath in glob.glob(pattern):
for filepath in filepaths:
featureDir = os.path.basename(os.path.dirname(filepath)) featureDir = os.path.basename(os.path.dirname(filepath))
routerFile = os.path.basename(filepath)[:-3] # Remove .py routerFile = os.path.basename(filepath)[:-3] # Remove .py