Skip to content

Commit

Permalink
Merge pull request #63 from eyra/copy-fs-fix
Browse files Browse the repository at this point in the history
fix copyFileToPyFS
  • Loading branch information
vloothuis authored Nov 11, 2023
2 parents cda5104 + cd0d14a commit 9d67d73
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/framework/processing/py_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,21 @@ function unwrap(response) {
}

function copyFileToPyFS(file, resolve) {
self.pyodide.FS.mkdir('/file-input')
directoryName = `/file-input`
pathStats = self.pyodide.FS.analyzePath(directoryName)
if (!pathStats.exists) {
self.pyodide.FS.mkdir(directoryName)
} else {
self.pyodide.FS.unmount(directoryName)
}
self.pyodide.FS.mount(
self.pyodide.FS.filesystems.WORKERFS,
{
files: [file]
},
'/file-input'
directoryName
)
resolve({ __type__: 'PayloadString', value: '/file-input/' + file.name })
resolve({ __type__: 'PayloadString', value: directoryName + '/' + file.name })
}

function initialise() {
Expand Down

0 comments on commit 9d67d73

Please sign in to comment.