Repository navigation
fix: remove import copies on project delete and refused imports - #14759
Conversation
…eletes A refused CSV/JSON import and a project deleted before its import runs both leave the copied file in the imports directory with no migration to remove it.
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Project delete cleared every per-project storage root except imports, so a file waiting for its migration outlived the project. The CSV and JSON import endpoints copied the file before checking the database and collection, so a refused request left a copy that no migration names and nothing would remove. Validate first, delete the imports root with the other roots, and mount the imports volume on the separate deletes worker so it can reach it.
|
Review complete. 🟡 1 medium 📍 Findings outside the diff (1) — 🟡 1 medium — defects on lines GitHub can't attach comments to🟡 Medium — Staged import copy leaks in // src/Appwrite/Platform/Modules/Migrations/Http/Migrations/CSV/Imports/Create.php
176 } elseif (!$deviceForFiles->copy($path, $newPath, $deviceForMigrations)) {
177 throw new \Exception('Unable to copy file');
178 }
179
180 $fileSize = $deviceForMigrations->getFileSize($newPath);Both import actions copy the uploaded file into the migrations device, but if 🧹 Nitpicks (1) — 🟢 1 low
The change hardens the CSV/JSON migration import endpoints by moving the database and collection lookup ahead of the file copy, so a bad target no longer leaves a staged copy on disk, and introduces lifecycle cleanup for the new imports storage device. Docker wiring gains the matching
Reviewed commit: 837fd45 |
🟢 Tier S · Ready to merge
This change removes a project's temporary migration-import directory during project cleanup, validates database and collection targets before CSV/JSON imports copy files, and mounts the imports volume in the separate deletes worker. It also adds E2E coverage for refused imports and project deletion with a pending import file.
📂 Walkthrough · 6
Reviewed |
fix: remove import copies on project delete and refused imports (cherry picked from commit f8bd84f)
Import copies in
/storage/imports/app-<projectId>/could outlive everything that names them.deleteProjectalso deletes the project's imports root (same guard: empty project ID is refused before any device is built)appwrite-worker-deleteshad no imports volumeappwrite-importsTests (E2E, pushed before the fix to show red):
MigrationsBase::testRefusedImportLeavesNoCopy: CSV and JSON import into a missing database returns 404 and leaves no*_<fileId>.*copy.ProjectsConsoleClientTest::testDeleteProjectRemovesPendingImports: a pending import file is gone after the project is deleted.Related: appwrite-labs/cloud#6628