Skip to content

Commit

Permalink
[jsondb] Restore zero byte files from backup (openhab#2155)
Browse files Browse the repository at this point in the history
* Restore zero byte files from backup
* Also handle zero byte backup files

Signed-off-by: Mike Major <mike_j_major@hotmail.com>
GitOrigin-RevId: 86a447c
  • Loading branch information
MikeJMajor authored and splatch committed Jul 11, 2023
1 parent 3159172 commit 3dc612d
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ public Collection<String> getKeys() {

@SuppressWarnings("unchecked")
private @Nullable Map<String, StorageEntry> readDatabase(File inputFile) {
if (inputFile.length() == 0) {
logger.warn("Json storage file at '{}' is empty - ignoring corrupt file.", inputFile.getAbsolutePath());
return null;
}

try {
final Map<String, StorageEntry> inputMap = new ConcurrentHashMap<>();

Expand Down

0 comments on commit 3dc612d

Please sign in to comment.