fix the unfixeble
This commit is contained in:
@@ -107,9 +107,20 @@ export async function checkpointDatabase(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
type WithTransactionImpl = <T>(work: (db: SQLiteDatabase) => Promise<T>) => Promise<T>;
|
||||
|
||||
let withTransactionOverride: WithTransactionImpl | null = null;
|
||||
|
||||
/** Test-only seam : les tests Node n'ont pas expo-sqlite, `syncRoot`/`syncDevice`
|
||||
* substituent leur transaction par un simple `work()`. `null` en production. */
|
||||
export function __setWithTransactionForTests(impl: WithTransactionImpl | null): void {
|
||||
withTransactionOverride = impl;
|
||||
}
|
||||
|
||||
export async function withTransaction<T>(
|
||||
work: (db: SQLiteDatabase) => Promise<T>,
|
||||
): Promise<T> {
|
||||
if (withTransactionOverride) return withTransactionOverride(work);
|
||||
return withDatabaseRetry(async (db) => {
|
||||
let result!: T;
|
||||
await db.withTransactionAsync(async () => {
|
||||
|
||||
@@ -150,6 +150,9 @@ export async function canAccess(
|
||||
|
||||
const exactCache = await getResourcePermission(resourceId, resourceType);
|
||||
if (exactCache) {
|
||||
if (exactCache.ownerId === deviceUserId) {
|
||||
return { allowed: true, access: 'owner', source: 'owner', stale: false, expiresAt: null };
|
||||
}
|
||||
if (exactCache.expiresAt != null && exactCache.expiresAt < now) {
|
||||
return {
|
||||
allowed: false,
|
||||
|
||||
@@ -66,4 +66,10 @@ export async function listFoldersChunked(
|
||||
};
|
||||
await visit(directoryUri);
|
||||
return result;
|
||||
}
|
||||
|
||||
export function listEntries(directoryUri: string): DirectoryEntry[] {
|
||||
const impl = walkImpl;
|
||||
if (!impl) throw new Error('SafWalkImpl not configured');
|
||||
return impl.list(directoryUri);
|
||||
}
|
||||
Reference in New Issue
Block a user