Delete migrated stores after closing the input stream

Fixes #1018
This commit is contained in:
AsamK 2022-10-03 13:37:49 +02:00
parent 5b5827f885
commit 333aacf4ab
2 changed files with 10 additions and 1 deletions

View file

@ -84,13 +84,18 @@ public class LegacyRecipientStore2 {
}).collect(Collectors.toMap(Recipient::getRecipientId, r -> r));
recipientStore.addLegacyRecipients(recipients);
Files.delete(file.toPath());
} catch (FileNotFoundException e) {
// nothing to migrate
} catch (IOException e) {
logger.warn("Failed to load recipient store", e);
throw new RuntimeException(e);
}
try {
Files.delete(file.toPath());
} catch (IOException e) {
logger.warn("Failed to load recipient store", e);
throw new RuntimeException(e);
}
}
private record Storage(List<Recipient> recipients, long lastId) {

View file

@ -52,6 +52,10 @@ public class LegacySenderKeySharedStore {
}
senderKeyStore.addLegacySenderKeysShared(sharedSenderKeys);
} catch (IOException e) {
logger.info("Failed to load shared sender key store, ignoring", e);
}
try {
Files.delete(file.toPath());
} catch (IOException e) {
logger.info("Failed to load shared sender key store, ignoring", e);