@Override protected RepoFile syncRepoFile(final LocalRepoTransaction transaction, final File file) { assertNotNull("transaction", transaction); assertNotNull("file", file); final File localRoot = getLocalRepoManager().getLocalRoot(); final RepoFileDao rfDao = transaction.getDao(RepoFileDao.class); RepoFile repoFile = rfDao.getRepoFile(localRoot, file); // If the type changed, we must delete the RepoFile here before invoking the super-method, // because this would otherwise cause an invocation of Cryptree.preDelete(...) causing // the actual file to be deleted. if (repoFile != null && !LocalRepoSync.create(transaction).isRepoFileTypeCorrect(repoFile, file)) { rfDao.deletePersistent(repoFile); repoFile = null; transaction.flush(); } repoFile = super.syncRepoFile(transaction, file); return repoFile; }