fix: move blob migration server-side, restore lightweight list loading
The client-side migration was downloading 25-50MB of base64 data to the browser before showing anything. getAllEntries also lost its lightweight flag. Fix: - New POST /api/storage/migrate-blobs endpoint runs entirely server-side (loads entries one-at-a-time from PostgreSQL, never sends heavy data to browser) - Restore lightweight:true on getAllEntries (strips remaining base64 in API) - Migration fires on mount (fire-and-forget) while list loads independently - Remove client-side migrateEntryBlobs function
This commit is contained in:
@@ -17,7 +17,6 @@ import {
|
||||
saveEntry,
|
||||
deleteEntry,
|
||||
generateRegistryNumber,
|
||||
migrateEntryBlobs,
|
||||
} from "../services/registry-service";
|
||||
import {
|
||||
createTrackedDeadline,
|
||||
@@ -54,18 +53,19 @@ export function useRegistry() {
|
||||
setLoading(false);
|
||||
}, [storage]);
|
||||
|
||||
// On mount: run migration (once), then load entries
|
||||
// On mount: trigger server-side blob migration (fire-and-forget), then load list
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
// Trigger server-side migration (runs inside Node.js, not browser)
|
||||
if (!migrationRan.current) {
|
||||
migrationRan.current = true;
|
||||
await migrateEntryBlobs(storage, blobStorage);
|
||||
fetch("/api/storage/migrate-blobs", { method: "POST" }).catch(() => {});
|
||||
}
|
||||
await refresh();
|
||||
};
|
||||
init();
|
||||
}, [refresh, storage, blobStorage]);
|
||||
}, [refresh]);
|
||||
|
||||
const addEntry = useCallback(
|
||||
async (
|
||||
|
||||
Reference in New Issue
Block a user