1 | svoid restoreLatestBackupIfConceptsFileEmpty(S dbID, O... _) { |
2 | bool doIt = boolPar doIt(_); |
3 | File file = conceptsFile(dbID); |
4 | if (fileExists(file) && fileSize(file) == 0) { |
5 | print(file + " corrupted, trying to restore"); |
6 | File backup = lastThat fileNotEmpty(sortByFileName(conceptBackupFiles(dbID))); |
7 | if (backup == null) ret with print("No usable backup found :("); |
8 | S msg = "RESTORING: " + backup; |
9 | File log = javaxDataDir("db-restores.log"); |
10 | if (doIt) logQuotedWithTime(log, msg); |
11 | print(stringIf(!doIt, "[would be] ") + msg); |
12 | if (doIt) { |
13 | clearConceptsOf(dbID); |
14 | copyFile(backup, file); |
15 | print(msg = "DB RESTORED!"); |
16 | if (doIt) logQuotedWithTime(log, msg); |
17 | } |
18 | } |
19 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1022129 |
Snippet name: | restoreLatestBackupIfConceptsFileEmpty |
Eternal ID of this version: | #1022129/4 |
Text MD5: | 7e8ae744f58c50ef1b3c5c4842ff3db5 |
Author: | stefan |
Category: | javax / concepts |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-03-08 10:33:55 |
Source code size: | 740 bytes / 19 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 310 / 367 |
Version history: | 3 change(s) |
Referenced in: | [show references] |