onProjectPreSave callback and virtualFileSystem grief

I’ve been tearing what little hair I have left trying to figure out touchdesigner’s callback system. I have a file that is using a virtual file system component. I’ve created an onProjectPreSave callback that seems to run file when doing a File → Save operation. However I want to unload all of the files in the virtualFileSystem so that my files aren’t bloated when saving to git.

The onProjectPreSave seems to run “op(‘vfsNode’).par.Remove.pulse()” and if I turn on the ‘Echo Commands To Textport’ parameter I see it print out that it has destroyed all of the virtual files… but the file size still seems bloated. If I save again (without loading the files) I’m getting the desired behaviour, but if I load all the files into vfs and save again, no bueno. There seems to be some operations happening out of order here - what am I missing?

The parameter Callbacks will not be executed until end of frame. So even though you are pusing the parameter before the preSave callabck finished, you are still only executing the clearing after the save is done.
Instead call the Remove function directly:
op("vfsNode").RemoveFiles()

1 Like