Skip to content

Commit

Permalink
Persist local file system for session
Browse files Browse the repository at this point in the history
  • Loading branch information
m90 committed Dec 22, 2024
1 parent f2d0cd2 commit 29ac7a5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ createApp({
requirements: '',
output: [],
filesPath: '/home/pyodide/pyla',
runtimeError: null
runtimeError: null,
nativefs: null
}
},
computed: {
Expand Down Expand Up @@ -52,8 +53,7 @@ createApp({
})
}

let nativefs
if (this.isUsingFilesystem) {
if (this.isUsingFilesystem && !this.nativefs) {
const dirHandle = await showDirectoryPicker()
const permissionStatus = await dirHandle.requestPermission({
mode: 'readwrite',
Expand All @@ -62,13 +62,13 @@ createApp({
if (permissionStatus !== 'granted') {
throw new Error('read access to directory not granted')
}
nativefs = await this.pyodide.mountNativeFS(this.filesPath, dirHandle)
this.nativefs = await this.pyodide.mountNativeFS(this.filesPath, dirHandle)
}

await this.pyodide.runPython(this.script)

if (nativefs) {
await nativefs.syncfs()
if (this.nativefs) {
await this.nativefs.syncfs()
}
} catch (err) {
this.runtimeError = err
Expand Down

0 comments on commit 29ac7a5

Please sign in to comment.