1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-08-10 22:11:50 +02:00

Chore: Web: Fix TypeMismatchWarning logged frequently on startup in dev mode (#12453)

This commit is contained in:
Henry Heino
2025-06-10 16:11:53 -07:00
committed by GitHub
parent 45d1d862a1
commit 7a611ac5c5

View File

@@ -54,8 +54,8 @@ export interface TransferableStat {
isDirectory: boolean;
}
const isNotFoundError = (error: DOMException) => error.name === 'NotFoundError';
const isTypeMismatchError = (error: DOMException) => error.name === 'TypeMismatchError';
const isNotFoundError = (error: Error) => error instanceof DOMException && error.name === 'NotFoundError';
const isTypeMismatchError = (error: Error) => error instanceof DOMException && error.name === 'TypeMismatchError';
const externalDirectoryPrefix = '/external/';
type AccessHandleDatabaseControl = {
@@ -240,8 +240,10 @@ export class WorkerApi {
handle = await parent.getDirectoryHandle(folderName, { create });
this.directoryHandleCache_.set(path, handle);
} catch (error) {
// TODO: Handle this better
logger.warn('Error getting directory handle', error, 'for', path, 'create:', create);
if (!isNotFoundError(error)) {
throw error;
}
handle = null;
}
@@ -402,7 +404,13 @@ export class WorkerApi {
public async stat(path: string, handle?: FileSystemDirectoryHandle|FileSystemFileHandle): Promise<TransferableStat|null> {
logger.debug('stat', path, handle ? 'with handle' : '');
try {
handle ??= await this.pathToDirectoryHandle_(path);
} catch (error) {
if (!isTypeMismatchError(error)) {
throw error;
}
}
try {
handle ??= await this.pathToFileHandle_(path);
} catch (error) {