diff --git a/python/edu/learn-python/src/com/jetbrains/python/edu/StudyDirectoryProjectGenerator.java b/python/edu/learn-python/src/com/jetbrains/python/edu/StudyDirectoryProjectGenerator.java index 41990be866b4..b8edda7b94ee 100644 --- a/python/edu/learn-python/src/com/jetbrains/python/edu/StudyDirectoryProjectGenerator.java +++ b/python/edu/learn-python/src/com/jetbrains/python/edu/StudyDirectoryProjectGenerator.java @@ -310,6 +310,13 @@ public class StudyDirectoryProjectGenerator extends PythonProjectGenerator imple File cashFile = new File(myCoursesDir, CACHE_NAME); PrintWriter writer = null; try { + if (!cashFile.exists()) { + final boolean created = cashFile.createNewFile(); + if (!created) { + LOG.error("Cannot flush courses cache. Can't create " + CACHE_NAME + " file"); + return; + } + } writer = new PrintWriter(cashFile); for (Map.Entry course : myCourses.entrySet()) { CourseInfo courseInfo = course.getKey(); @@ -322,6 +329,9 @@ public class StudyDirectoryProjectGenerator extends PythonProjectGenerator imple catch (FileNotFoundException e) { LOG.error(e); } + catch (IOException e) { + LOG.error(e); + } finally { StudyUtils.closeSilently(writer); }