Browse Source

remove unneeded dependency, use try catch when writing files

pull/18/head
Jannik 2 years ago
parent
commit
fe72c02562
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
  1. 1
      build.gradle
  2. 12
      src/main/kotlin/org/mosad/thecitadelofricks/controller/CacheController.kt

1
build.gradle

@ -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'

12
src/main/kotlin/org/mosad/thecitadelofricks/controller/CacheController.kt

@ -190,12 +190,16 @@ 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))
writer.write(Gson().toJson(timetable))
writer.close()
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()
}
}
/**

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close