From ea34e37744369167102d60826ba74a44504c947f Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Thu, 14 Aug 2014 19:25:05 +0400 Subject: [PATCH] fixed FileNotFoundException in StudyDirectoryProjectGenerator --- .../python/edu/StudyDirectoryProjectGenerator.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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); }