files.add(configuration.getIdentitiesFile()); files.add(configuration.getAddressBookFile()); File[] emailFolders = new File[] {configuration.getInboxDir(), configuration.getOutboxDir(), configuration.getSentFolderDir(), configuration.getTrashFolderDir()};; for (File dir: emailFolders) files.addAll(Arrays.asList(dir.listFiles()));
migrateEmailsIfNeeded(configuration.getInboxDir()); migrateEmailsIfNeeded(configuration.getOutboxDir()); migrateEmailsIfNeeded(configuration.getSentFolderDir());
/** * This method won't corrupt any data if the data has already been migrated to the latest version, * because only unencrypted files are converted. * @param configuration * @throws Exception */ void migrateIfNeeded(Configuration configuration) throws Exception { log.debug("Migrating any pre-0.2.7 files..."); passwordCache = new PasswordCache(configuration); // encrypt with the default password passwordCache.setPassword(new byte[0]); // convert metadata in email folders migrateMetadataIfNeeded(configuration.getInboxDir()); migrateMetadataIfNeeded(configuration.getOutboxDir()); migrateMetadataIfNeeded(configuration.getSentFolderDir()); migrateMetadataIfNeeded(configuration.getTrashFolderDir()); }
/** * Initializes objects for accessing emails and packet files on the filesystem. * @param passwordCache */ private void initializeFolderAccess(PasswordCache passwordCache) { inbox = new EmailFolder(configuration.getInboxDir(), passwordCache); outbox = new Outbox(configuration.getOutboxDir(), passwordCache); sentFolder = new EmailFolder(configuration.getSentFolderDir(), passwordCache); trashFolder = new TrashFolder(configuration.getTrashFolderDir(), passwordCache); relayPacketFolder = new RelayPacketFolder(configuration.getRelayPacketDir()); MessageIdCache messageIdCache = new MessageIdCache(configuration.getMessageIdCacheFile(), configuration.getMessageIdCacheSize()); incompleteEmailFolder = new IncompleteEmailFolder(configuration.getIncompleteDir(), messageIdCache, inbox); emailDhtStorageFolder = new EmailPacketFolder(configuration.getEmailDhtStorageDir()); indexPacketDhtStorageFolder = new IndexPacketFolder(configuration.getIndexPacketDhtStorageDir()); directoryDhtFolder = new DirectoryEntryFolder(configuration.getDirectoryEntryDhtStorageDir()); }