Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use actual temp files and directories #20

Open
brentp opened this issue Jul 24, 2018 · 2 comments
Open

use actual temp files and directories #20

brentp opened this issue Jul 24, 2018 · 2 comments
Labels
enhancement New feature or request

Comments

@brentp
Copy link
Collaborator

brentp commented Jul 24, 2018

currently we use /tmp/x.html. should use a real temp file and temporary directory.

@brentp brentp added the enhancement New feature or request label Jul 24, 2018
@timotheecour
Copy link
Contributor

timotheecour commented Jan 26, 2019

yes but that's not enough; currently lots of things are broken by fact x.html is deleted right after browser opens it:

  • curl file:///private/tmp/x.html doesn't work
  • refresh doesn't work (gives 404)
  • chrome => view page source doesn't work

proposal 1 (trivial)

  • expose in nim API user-configurable file where html is saved (instead of result = "/tmp/x.html")
  • if provided, use it and do not delete it after it was written to; else use current logic

proposal 2 (in addition to proposal 1)

when user didn't provide that file path:

proposal 3 (if needed, down the line...) tempfile garbage collection

note: this is a generally useful feature that should be implemented in another package

  • Use some temp file garbage collection to periodically remove the oldest temp files that were created
  • an index.json is created/updated in same dir as temp files being created is updated each time a temp file is added
  • the index.json specifies N=the max number of files kept; when that number is exceeded, the oldest temp files are removed (oldest in the sense of lastAccessTime for OS that support it, maybe), so that no more than N files remain
  • the index.json can also have a reference to files that shouldn't be removed
  • a nice nim API abstracts all of this into something nice and simple like:
let tempFile = createManagedTempFile(config = Config(dir = getTempDir(), maxFiles = 100, ...))
``

@Vindaar
Copy link
Member

Vindaar commented Jan 26, 2019

I think proposal 2 for a start would be great. I agree that proposal 3 would be nice, but as you said, it should be a separate library.

I'd argue that for most use cases not removing files shouldn't be an issue. The space needed even for > 100 plots is still small. In use cases where this is an issue, I would think the user would not go with a JS based plotting library anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants