diff --git a/src/framework/processing/py_worker.js b/src/framework/processing/py_worker.js index 70ec0542..f6d79c14 100755 --- a/src/framework/processing/py_worker.js +++ b/src/framework/processing/py_worker.js @@ -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() {