mirror of
https://github.com/sqlite/sqlite.git
synced 2025-12-24 14:17:58 +03:00
Minor internal cleanups and docs in the OPFS sqlite3_vfs.
FossilOrigin-Name: 61799b05ff232c2ac349169c27bfe7f8d9277366093b0c9dd2739828993b3066
This commit is contained in:
@@ -290,7 +290,9 @@ const installOpfsVfs = function callee(options){
|
||||
The size of the block in our SAB for serializing arguments and
|
||||
result values. Needs to be large enough to hold serialized
|
||||
values of any of the proxied APIs. Filenames are the largest
|
||||
part but are limited to opfsVfs.$mxPathname bytes.
|
||||
part but are limited to opfsVfs.$mxPathname bytes. We also
|
||||
store exceptions there, so it needs to be long enough to hold
|
||||
a reasonably long exception string.
|
||||
*/
|
||||
state.sabS11nSize = opfsVfs.$mxPathname * 2;
|
||||
/**
|
||||
|
||||
@@ -239,15 +239,26 @@ const installAsyncProxy = function(self){
|
||||
between locking-related failures and other types, noting that we
|
||||
cannot currently do so because createSyncAccessHandle() does not
|
||||
define its exceptions in the required level of detail.
|
||||
|
||||
2022-11-29: according to:
|
||||
|
||||
https://github.com/whatwg/fs/pull/21
|
||||
|
||||
NoModificationAllowedError will be the standard exception thrown
|
||||
when acquisition of a sync access handle fails due to a locking
|
||||
error. As of this writing, that error type is not visible in the
|
||||
dev console in Chrome v109, nor is it documented in MDN, but an
|
||||
error with that "name" property is being thrown from the OPFS
|
||||
layer.
|
||||
*/
|
||||
class GetSyncHandleError extends Error {
|
||||
constructor(errorObject, ...msg){
|
||||
super();
|
||||
this.error = errorObject;
|
||||
this.message = [
|
||||
...msg, ': Original exception ['+errorObject.name+']:',
|
||||
super([
|
||||
...msg, ': '+errorObject.name+':',
|
||||
errorObject.message
|
||||
].join(' ');
|
||||
].join(' '), {
|
||||
cause: errorObject
|
||||
});
|
||||
this.name = 'GetSyncHandleError';
|
||||
}
|
||||
};
|
||||
@@ -259,8 +270,12 @@ const installAsyncProxy = function(self){
|
||||
distinguish that from other errors.
|
||||
|
||||
This approach is highly questionable.
|
||||
|
||||
Note that even if we return SQLITE_IOERR_LOCK from here,
|
||||
it bubbles up to the client as a plain I/O error.
|
||||
*/
|
||||
return (e instanceof GetSyncHandleError)
|
||||
return (e instanceof GetSyncHandleError
|
||||
&& e.cause.name==='NoModificationAllowedError')
|
||||
? state.sq3Codes.SQLITE_IOERR_LOCK
|
||||
: rc;
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user