void (final File dir) { indicateMinor(dir.getPath()); final File[] files = dir.listFiles(); if (files == null) { return; } for (File item : files) { if (item.isDirectory()) { cleanUpSkeletons(item); // was the dir emptied? File[] remaining = item.listFiles(); if (remaining != null && remaining.length == 0) { mySkeletonsGenerator.deleteOrLog(item); } else if (remaining != null && remaining.length == 1) { //clean also if contains only __init__.py File lastFile = remaining[0]; if (PyNames.INIT_DOT_PY.equals(lastFile.getName()) && lastFile.length() == 0) { boolean deleted = mySkeletonsGenerator.deleteOrLog(lastFile); if (deleted) mySkeletonsGenerator.deleteOrLog(item); } } } else if (item.isFile()) { // clean up an individual file final String itemName = item.getName(); if (PyNames.INIT_DOT_PY.equals(itemName) && item.length() == 0) continue; // these are versionless if (PySkeletonGenerator.BLACKLIST_FILE_NAME.equals(itemName)) continue; // don't touch the blacklist if (PySkeletonGenerator.STATE_MARKER_FILE.equals(itemName)) continue; if (PySdkUtil.getBuiltinsFileName(mySdk).equals(itemName)) { continue; } final PySkeletonHeader header = PySkeletonHeader.readSkeletonHeader(item); String binaryFile = null; boolean canLive = header != null; if (canLive) { binaryFile = header.getBinaryFile(); canLive = PySkeletonHeader.PREGENERATED.equals(binaryFile) || PySkeletonHeader.BUILTIN_NAME.equals(binaryFile) || mySkeletonsGenerator.exists(binaryFile); } if (!canLive) { LOG.debug("Cleaning up skeleton " + item + (binaryFile != null ? " for non existing binary " + binaryFile : "")); mySkeletonsGenerator.deleteOrLog(item); } } } }