remove unneeded dependency, use try catch when writing files
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Jannik 2020-06-06 20:53:23 +02:00
parent 8d9fcd3d7c
commit fe72c02562
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
2 changed files with 8 additions and 5 deletions

View File

@ -14,7 +14,6 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
implementation 'org.jsoup:jsoup:1.13.1'

View File

@ -190,13 +190,17 @@ class CacheController {
* @param timetable a timetable of the type [TimetableCourseWeek]
*/
private fun saveTimetableToCache(timetable: TimetableCourseWeek) {
println(timetable.timetable.toString())
val file = File(StartupController.dirTcorCache, "timetable-${timetable.meta.courseName}-${timetable.meta.weekIndex}.json")
val writer = BufferedWriter(FileWriter(file))
try {
writer.write(Gson().toJson(timetable))
} catch (e: Exception) {
logger.error("something went wrong while trying to write a cache file", e)
} finally {
writer.close()
}
}
/**
* before the APIController is up, get the data fist