in agent/src/jetbrains/buildServer/swabra/snapshots/iteration/FileSystemFilesIterator.java [37:91]
public FileInfo getNext() throws IOException {
boolean postProcess = true;
while (true) {
if (myIterators == null) {
myIterators = new Stack<Iterator<File>>();
return processFolder(myRootFolder, myRules.shouldInclude(myRootFolder.getPath()));
}
if (myIterators.size() > MAX_DEPTH) {
final StringBuilder builder = new StringBuilder();
int iteratorsCount = myIterators.size();
for (int i=0; i<iteratorsCount; i++){
final Iterator<File> iterator = myIterators.get(i);
if (iterator.hasNext()) {
builder.append(iterator.next().getAbsolutePath());
} else {
builder.append("<Empty iterator>");
}
builder.append("\n");
}
LOG.warn("Too many entries in depth (" + iteratorsCount + "). Printing the list: \n" + builder.toString());
throw new IOException("Too many entries in depth. Is there a loop. Current folder depth is more than " + MAX_DEPTH);
}
if (myIterators.isEmpty()) {
return null;
}
final Iterator<File> it = myIterators.peek();
while (it.hasNext()) {
final File next = it.next();
boolean shouldInclude = myRules.shouldInclude(next.getPath());
if ((next.isDirectory() && myRequiresListing) || shouldInclude) {
if (next.isFile()) {
return createFileInfo(next);
} else if (next.isDirectory()) {
FileInfo processResult = processFolder(next, shouldInclude);
if (processResult != null)
return processResult;
else {
//return getNext();
postProcess = false;
break;
}
} else {
throw new IOException("Failed to read " + next);
}
}
}
if (postProcess) {
myIterators.pop();
if (myIterators.isEmpty()) {
return null;
}
}
postProcess = true;
}
}