One-off, idempotent repair of the images embedded in notes migrated out
of Space.
The main Space removal migration (MigrateProjectDataFromSpace) was run
before project notes supported images. It converted each Space Constellab
document into a local rich-text NOTE, copying the content verbatim — so the
figure references (their filenames) were kept, but the image bytes were
never downloaded into the note's local directory. As a result the images of
those migrated notes are broken.
For every NOTE that was migrated from Space (i.e. has a
space_document_id), this task:
- reads the note's rich-text content and finds its
FIGURE blocks,
- for each figure whose image file is missing on disk, downloads the bytes
from Space and writes them under the note's dedicated directory,
keeping the same filename so the content is left untouched.
The task is idempotent: a figure whose file already exists locally is
skipped, so re-running only fetches what is still missing (and a note whose
images are all present is a no-op). It never writes to Space and
never mutates the note content. Per-figure and per-note errors are
reported and never abort the run.
Config:
dry_run (default True): only report which figures would be
downloaded, without fetching or writing anything. Run once with
dry_run=True, review the report, then re-run with dry_run=False.
Output: a JSON report with per-note counts and details (figures repaired,
already present, errors, failed notes).