Make sure the sketch hasn't been moved or deleted by a nefarious user. If they did, try to re-create it and save. Only checks whether the main folder is still around, but not its contents.
()
| 1514 | * main folder is still around, but not its contents. |
| 1515 | */ |
| 1516 | public void ensureExistence() { |
| 1517 | if (!folder.exists()) { |
| 1518 | // Avoid an infinite loop if we've already warned about this |
| 1519 | // https://github.com/processing/processing/issues/4805 |
| 1520 | if (!disappearedWarning) { |
| 1521 | disappearedWarning = true; |
| 1522 | |
| 1523 | // Disaster recovery, try to salvage what's there already. |
| 1524 | Messages.showWarning(Language.text("ensure_exist.messages.missing_sketch"), |
| 1525 | Language.text("ensure_exist.messages.missing_sketch.description")); |
| 1526 | try { |
| 1527 | folder.mkdirs(); |
| 1528 | modified = true; |
| 1529 | |
| 1530 | for (int i = 0; i < codeCount; i++) { |
| 1531 | code[i].save(); // this will force a save |
| 1532 | } |
| 1533 | calcModified(); |
| 1534 | |
| 1535 | } catch (Exception e) { |
| 1536 | // disappearedWarning prevents infinite loop in this scenario |
| 1537 | Messages.showWarning(Language.text("ensure_exist.messages.unrecoverable"), |
| 1538 | Language.text("ensure_exist.messages.unrecoverable.description"), e); |
| 1539 | } |
| 1540 | } |
| 1541 | } |
| 1542 | } |
| 1543 | |
| 1544 | |
| 1545 | /** |
no test coverage detected