Notes on file access and caching » History » Version 2
Notes on file access and caching¶
When running a MATLAB function in the MATLAB Compiler Runtime environment, it seems to be good practice to avoid using the current working directory. When the function is run it is first unpacked into a temporary cache location whose location is not predictable.
Rather than try to discover that location so that an external process can feed input files to the function and receive outputs, it seems more reliable to tell the MATLAB code what directory to use for its input and output files.
What the web app does at the moment¶
The web app has a configuration file which can be found in
This specifies directories for input and output files:
These need to be set correctly when deploying the web application.
indir should point to the directory containing input data, in this case
outdir should point to a directory writable by the Tomcat process owner, in which the MATLAB code will put its generated files. The app won't be able to create this directory or to use it if it has the wrong permissions, so it's up to the user deploying the site to handle that.
Currently the app does no caching -- the generated files are regenerated on every request.
We need to
- keep a central location for successfully generated files, with names uniquely identifying their generation parameters, and serve audio from that if it is found there
- keep a separate location for the MATLAB process to write its outputs in (different from the above so that we don't serve any half-written files)
- move files from one to the other after the MATLAB process finishes and before serving them to the client