Closed ferrarimartin closed 6 years ago
Class edu.xtec.jclic.FileSystem#SecureFileOutputStream has been modified to avoid this kind of errors. The original workflow when saving projects was:
1 - Create a temporary ZIP file
2 - Write the project definition (.jclic
file) and needed ingredients (images, sounds...) into this temporary file.
3 - If something goes wrong, catch the exception and notify the user about the error found. The project state remains as "unsaved", and the original file has been not modified.
4 - From here, we assume that everything went well. The temporary ZIP file contains the saved project and is in good condition.
5 - Replace the original project file with the temporary ZIP file. This is done deleting the original file and, then, renaming the temporary.
In some cases, and for unknown reasons, the assertion made in step 4 is not met. Actually, the temporary file is corrupted and no error or exception is thrown by the Java engine. This results in the loss of the original project.
Now, since JClic v0.3.2.0, we perform an additional step:
2b - Open the temporary file, read its the ZIP directory and check for empty or inaccessible files inside it. If something goes wrong, throw an IOException.
Hope this will reduce the risk of producing corrupted files when saving projects. Please notify us if the problem appears again.
Thanks for reporting!
Thank you so much Francesc. I've added some missing translations for portuguese in launchpad, in case they are useful.