import { readFile, rename } from 'node:fs/promises'; import path from 'node:path'; import { logger } from '@/lib/logger'; import { isSharedMode } from '@/lib/shared-store'; import { versionOf } from '@/lib/shared-store/keys'; import { serializeLocal } from '@/lib/shared-store/local'; import type { DocCollection, StoredDoc } from '@/lib/shared-store/types'; /** * Put a user's document that no longer decrypts out of the way, so the * user can save again, without losing its bytes (#1066). It most likely was * written with another session secret (rotated, or a replica that had its * own); with that secret back it can be restored by hand. * * - Local mode: renamed to `.unreadable-