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

Allow file system operations to be tracked for safe deletion of untouched files #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

justin-espedal
Copy link

This is the hxp part of a potential solution to openfl/lime#1546 (Stale output from previous builds can cause errors).

By tracking all files in a folder before starting file operations, and determining which files are still live based on the file operations performed, we can then safely delete all files which are determined to be stale.

markAllFilesInFolderAsUntouched is to be called before a batch of file operations targeting a specific folder. If any file operations are performed directly by the caller instead of using hxp's System functions, those file operations should be accompanied by markFileAsTouched. Finally, deleteUntouchedFiles can be called to remove stale files from the destination folder.

We avoid unnecessary file operations where possible, because avoiding
file IO is faster, and it also helps build systems that depend on
file modification times to detect modification.

Unfortunately, this means we can't just delete an entire folder and
start from scratch again. Stale files may still exist after re-copying
a set of files where some of the original files have since been deleted.

By tracking all files in a folder before starting file operations, and
determining which files are still live based on the file operations
performed, we can then safely delete all files which are determined
to be stale.

markAllFilesInFolderAsUntouched is to be called before a batch of file
operations targeting a specific folder. If any file operations are
performed by third-party libraries, those should be accompanied by
markFileAsTouched. Finally, deleteUntouchedFiles can be called to
remove stale files from the destination folder.
If certain external file operations cannot be tracked,
markAllFilesStateAsUnknown should be used. This will prevent
any files from being deleted. The project should be manually
cleaned by the user in this case.
@player-03
Copy link
Contributor

This can be closed now that we've merged openfl/lime#1790.

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

Successfully merging this pull request may close these issues.

2 participants