1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Export: Remove temp files from cache after export

So far we left most temporary files lying around, so this attempts to
fix that.

I added a helper method to DirAccess to factor out the boilerplate of
creating a DirAccess, checking if the file exists, remove it or print
an error on failure.
This commit is contained in:
Rémi Verschelde
2019-08-09 13:45:30 +02:00
parent 5441aaf768
commit 37a16fee05
10 changed files with 194 additions and 117 deletions

View File

@@ -362,12 +362,21 @@ int EditorExportPlatformJavaScript::get_device_count() const {
Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) {
String path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_export.html");
String basepath = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_js_export");
String path = basepath + ".html";
Error err = export_project(p_preset, true, path, p_debug_flags);
if (err) {
if (err != OK) {
// Export generates several files, clean them up on failure.
DirAccess::remove_file_or_error(basepath + ".html");
DirAccess::remove_file_or_error(basepath + ".js");
DirAccess::remove_file_or_error(basepath + ".pck");
DirAccess::remove_file_or_error(basepath + ".png");
DirAccess::remove_file_or_error(basepath + ".wasm");
return err;
}
OS::get_singleton()->shell_open(String("file://") + path);
// FIXME: Find out how to clean up export files after running the successfully
// exported game. Might not be trivial.
return OK;
}