Update: Python Online板卡下「本地文件系统」增加对本地目录操作对象的缓存
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { WebAccessFS } from '@zenfs/dom';
|
||||
import { get, set } from 'idb-keyval';
|
||||
import { FS } from 'mixly';
|
||||
|
||||
|
||||
@@ -32,6 +33,20 @@ export default class FileSystemFS extends FS {
|
||||
if (permissionStatus !== 'granted') {
|
||||
throw new Error('readwrite access to directory not granted');
|
||||
}
|
||||
await set('mixly-pyodide-fs', directoryHandle);
|
||||
this.#fs_ = new WebAccessFSExt(directoryHandle);
|
||||
return directoryHandle;
|
||||
}
|
||||
|
||||
async loadFS() {
|
||||
let directoryHandle = await get('mixly-pyodide-fs');
|
||||
if (!directoryHandle) {
|
||||
return null;
|
||||
}
|
||||
const permissionStatus = await directoryHandle.requestPermission({ mode: 'readwrite' });
|
||||
if (permissionStatus !== 'granted') {
|
||||
throw new Error('readwrite access to directory not granted');
|
||||
}
|
||||
this.#fs_ = new WebAccessFSExt(directoryHandle);
|
||||
return directoryHandle;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user