in intellij-plugin/educational-core/src/com/jetbrains/edu/learning/framework/impl/FrameworkLessonManagerImpl.kt [74:109]
override fun updateUserChanges(task: Task, newInitialState: FLTaskState) {
require(project.isStudentProject()) {
"`updateUserChanges` should be called only if course in study mode"
}
require(task.lesson is FrameworkLesson) {
"Only solutions of framework tasks can be saved"
}
val currentRecord = task.record
if (currentRecord == -1) return
val changes = try {
storage.getUserChanges(currentRecord)
}
catch (e: IOException) {
LOG.error("Failed to get user changes for task `${task.name}`", e)
return
}
val newChanges = changes.changes.mapNotNull {
when (it) {
is Change.AddFile -> if (it.path in newInitialState) Change.ChangeFile(it.path, it.contents) else it
is Change.RemoveFile -> if (it.path !in newInitialState) null else it
is Change.ChangeFile -> if (it.path !in newInitialState) Change.AddFile(it.path, it.contents) else it
is Change.PropagateLearnerCreatedTaskFile,
is Change.RemoveTaskFile -> it
}
}
try {
storage.updateUserChanges(currentRecord, UserChanges(newChanges))
}
catch (e: IOException) {
LOG.error("Failed to update user changes for task `${task.name}`", e)
}
}