+ private List<AccountsStorage.Account> readAccounts() throws IOException {
+ final var pair = openFileChannel(getAccountsFile());
+ try (final var fileChannel = pair.first(); final var lock = pair.second()) {
+ final var storage = readAccountsLocked(fileChannel);
+
+ var accountsVersion = storage.version() == null ? 1 : storage.version();
+ if (accountsVersion > CURRENT_STORAGE_VERSION) {
+ throw new IOException("Accounts file was created by a more recent version: " + accountsVersion);
+ } else if (accountsVersion < MINIMUM_STORAGE_VERSION) {
+ throw new IOException("Accounts file was created by a no longer supported older version: "
+ + accountsVersion);
+ } else if (accountsVersion < CURRENT_STORAGE_VERSION) {
+ return upgradeAccountsFile(fileChannel, storage, accountsVersion).accounts();
+ }
+ return storage.accounts();
+ }
+ }
+
+ private AccountsStorage upgradeAccountsFile(
+ final FileChannel fileChannel, final AccountsStorage storage, final int accountsVersion
+ ) {