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

Is there a proper way to purge the temp directory? #24

Closed
uliska opened this issue Jan 15, 2018 · 7 comments
Closed

Is there a proper way to purge the temp directory? #24

uliska opened this issue Jan 15, 2018 · 7 comments
Assignees

Comments

@uliska
Copy link
Collaborator

uliska commented Jan 15, 2018

the lilypond temp directory will grow really fast, with a full set of files for any modification of any score (even size changes). There should be a nice way to purge the temp directory, although it may be difficult to decide what to throw out.

One idea (that could be implemented as a package option purge) would be to remove all files from the temp directory that are not actually used by the document. For this to work all generated hash filenames should be stored in a list (can conveniently be done in the new function hash_output_filename introduced in 923a28a) and at the end of the LaTeX run all files from the temp directory that don't belong to any of the hashes are removed.

Of course this could trigger unnecessary LilyPond runs, for example when the line width is temporarily modified and later reverted. But that's why it would be a package option and not built in.

@jperon
Copy link
Owner

jperon commented Jan 15, 2018

We could have such an option ; another one would be just to write the list, and to document it so that users may use third-party tools to remove unused files (from a Makefile or such).

@rpspringuel
Copy link
Collaborator

I just want to chime in and say that having a well defined temporary directory makes it easier on existing purge functions, such as those which might be present in an editor. I have a feature request which I will be reiterating in about a month (the developer is too busy at the moment to work on it) to allow TeXShop to delete temporary directories when it deletes auxiliary files. Being able to easily identify the appropriate directory to delete is critical to making such a feature usable.

@uliska
Copy link
Collaborator Author

uliska commented Jan 15, 2018

I would say this responsibility may well be left to the user (to use a given default temp directory or select their own). In addition different editors may have different "thoughts" about default directories ...

We could have such an option ; another one would be just to write the list, and to document it so that users may use third-party tools to remove unused files (from a Makefile or such).

This is of course a good idea. In that case I would vote for both: write a list with written/used files (that may or may not become also useful for versioning strategies) and offer the option to purge the temp directory. Maybe writing a list could be done always (or at least be on by default) while purge (or purge-ly-dir) could be a package option (i.e. off by default).

@jperon
Copy link
Owner

jperon commented Jan 15, 2018

This issue is partially solved by 33eca91 :

  • a tmpdir package options lets one define another temporary directory ;
  • a FILENAME.list is written within the temporary directory.

For now, FILENAME.list contains only the hash of the content, which I think should be enough to write custom scripts to clean that directory.

@uliska
Copy link
Collaborator Author

uliska commented Jan 15, 2018

For now, FILENAME.list contains only the hash of the content, which I think should be enough to write custom scripts to clean that directory.

Yes, I think so. I will test tomorrow, that will make more sense ;-)

@uliska
Copy link
Collaborator Author

uliska commented Jan 18, 2018

One reasonable behaviour would be to use FILENAME.list to purge only files from the current document that are no longer used. Or more concretely that had been used in the previous run but not anymore. While this may still delete files that are used by another document that should be much less of an issue than when globally purging the temp directory.

For this to work:

  • FILENAME.list is read in first so we know what has been used last time
  • while typestting build a new list of used files (regardless of whether they are compiled newly or not)
  • After finishing the typestting check which hashes from the "old" list are not in the "new" list
  • Delete this subset
  • write out the "new" list as FILENAME.list

@jperon jperon self-assigned this Jan 23, 2018
@jperon jperon mentioned this issue Jan 23, 2018
@uliska
Copy link
Collaborator Author

uliska commented Jan 24, 2018

Fixed in #43

@uliska uliska closed this as completed Jan 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants