EDU-642 Local course doesn't replace its old version
[idea/community.git] / python / educational-core / student / src / com / jetbrains / edu / learning / courseGeneration / StudyProjectGenerator.java
index 0d2245936a940c9c3faaec831b0ca4ef82d3329b..02249eab36883c103d2b1fea0f0e71ff660c6282 100644 (file)
@@ -478,7 +478,11 @@ public class StudyProjectGenerator {
       flushCache(myCourses);
       if (courseName != null && !courseName.getName().equals(unzippedName)) {
         //noinspection ResultOfMethodCallIgnored
-        courseDir.renameTo(new File(OUR_COURSES_DIR, courseName.getName()));
+        File dest = new File(OUR_COURSES_DIR, courseName.getName());
+        if (dest.exists()) {
+          FileUtil.delete(dest);
+        }
+        courseDir.renameTo(dest);
         //noinspection ResultOfMethodCallIgnored
         courseDir.delete();
       }