Github user anmolnar commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/450#discussion_r163457798 --- Diff: src/java/main/org/apache/zookeeper/server/persistence/FileTxnSnapLog.java --- @@ -136,13 +136,51 @@ public FileTxnSnapLog(File dataDir, File snapDir) throws IOException { throw new DatadirException("Cannot write to snap directory " + this.snapDir); } + // check content of transaction log and snapshot dirs if they are two different directories + if(!this.dataDir.getPath().equals(this.snapDir.getPath())){ + checkLogDir(); + checkSnapDir(); + } + txnLog = new FileTxnLog(this.dataDir); snapLog = new FileSnap(this.snapDir); autoCreateDB = Boolean.parseBoolean(System.getProperty(ZOOKEEPER_DB_AUTOCREATE, ZOOKEEPER_DB_AUTOCREATE_DEFAULT)); } + private void checkLogDir() throws LogdirContentCheckException { + File[] files = this.dataDir.listFiles(); --- End diff -- I prefer writing (and later reading) less code than more. You could be right about the performance impact, but at least `listFiles()` will only create File objects for the matching files, not for all of them.
---