openExclusive static method
Exclusive SQLite lock-byte-range lease for a single owning Dart isolate. On POSIX, ANY other descriptor close can drop process locks, and other isolates can obtain overlapping locks. All handles in a process must be coordinated by one owner; this is not a general cross-isolate lock manager.
Implementation
static Future<DurableFileStorageBackend> openExclusive(String path,
{required bool directoryEntryIsDurable}) async {
final canonical = await File(path).resolveSymbolicLinks();
if (!_leases.add(canonical)) {
throw StateError('Database already leased in this isolate');
}
DurableFileStorageBackend? storage;
try {
storage = await openExisting(canonical,
directoryEntryIsDurable: directoryEntryIsDurable);
await storage._file.lock(FileLock.exclusive, 0x40000000, 0x40000200);
storage._lockPath = canonical;
return storage;
} catch (_) {
_leases.remove(canonical);
await storage?.close();
rethrow;
}
}