fixed FileNotFoundException in StudyDirectoryProjectGenerator

This commit is contained in:
Ekaterina Tuzova
2014-08-14 19:25:05 +04:00
parent f8d4a23ceb
commit ea34e37744
@@ -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<CourseInfo, File> 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);
}