Files
Schulcloud-MCP/local-instance/scripts/minio-init.sh
MechaCat02 bed3923902 Browse the file manager ("Dateien") as a filesystem
Many teachers never use topics or boards; their material sits in the
course's file area, and the tools answered "0 files" for courses holding
dozens of worksheets — 21 of 26 courses on the live account. Persönliche,
Kurs-, Team- and Geteilte Dateien live in the legacy file store, not in
files-storage, and its service is not in the public ingress. The only way in
is the legacy client: HTML listings, and GET /files/signedurl for a
pre-signed download.

core/legacy-files.ts turns that into one path tree — /my, /courses/<course>,
/teams/<team>, /shared — resolving names that contain "/", ids anywhere in a
path, and wrong or ambiguous names with a message saying what is there. A
listing that does not parse throws; it never reads as an empty folder.

Some of the legacy client's GET routes write (GET /files/share/ mints a
share token), so getFileManagerPage allows only the listing routes, by
pattern. Signed URLs are fetched with no credentials and must be https.

- MCP: fs_list, fs_tree, fs_find and fs_read; get_course lists course files.
- CLI: schulcloud fs ls, tree, find and get, recursive and resumable.
- API: /api/fs/list, tree, find and file.
- Index: the crawl walks the file manager (INDEX_FILE_MANAGER, on by
  default), so search covers the text inside those files and sync mirrors
  them under <course>/Kurs-Dateien.

The local instance gains a fixture for all four areas. It needed a loopback,
so signed URLs open from the host, and a pre-created bucket, since MinIO
does not implement PutBucketCors.

135 tests. Smoke 55/55 live; 57/57 and 55/55 on the local instance.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 20:19:16 +02:00

27 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Creates the buckets each service expects. MinIO does not create them on
# demand: file-storage reports a generic 500 on upload if its bucket is
# missing, and the h5p library job fails halfway through.
set -eu
mc alias set local http://minio:9000 miniouser miniouser
for bucket in \
schulcloud ` # files-storage (the /api/v3/file API)` \
h5p-content-bucket ` # h5p-editor content` \
h5p-library-bucket ` # h5p content types` \
ydocs ` # tldraw whiteboard documents` \
fwu-content ` # FWU media, unused but cheap to create` \
bucket-5f2987e020834114b8efd6f6 # legacy file manager, demo school (see below)
do
mc mb --ignore-existing "local/$bucket"
done
# The legacy file manager keeps one bucket per school, "bucket-<schoolId>", and
# creates it on first upload — then calls PutBucketCors, which MinIO does not
# implement, so the first upload fails with "A header you provided implies
# functionality that is not implemented". A bucket that already exists skips
# both calls. 5f2987e020834114b8efd6f6 is the demo school's fixed seed id.
mc ls local