Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Commit

Permalink
fix(player): Clear file before writing for export
Browse files Browse the repository at this point in the history
  • Loading branch information
defvs committed Nov 9, 2020
1 parent 37bbe60 commit 15b9c07
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/xerus/monstercat/api/Player.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ object Player: FadingHBox(true, targetHeight = 25) {
fun reset() {
fadeOut()
if(!Files.isDirectory(Settings.PLAYEREXPORTFILE())) {
Files.write(Settings.PLAYEREXPORTFILE(), arrayListOf(""), StandardOpenOption.CREATE)
Files.newBufferedWriter(Settings.PLAYEREXPORTFILE(),
StandardOpenOption.TRUNCATE_EXISTING,
StandardOpenOption.WRITE,
StandardOpenOption.CREATE
).close()
logger.debug("Cleared export file (${Settings.PLAYEREXPORTFILE()}) from its contents")
}
GlobalScope.launch {
Expand Down Expand Up @@ -166,10 +170,12 @@ object Player: FadingHBox(true, targetHeight = 25) {
setOnReady {
label.text = "Now Playing: $track"
if(!Files.isDirectory(Settings.PLAYEREXPORTFILE())) {
Files.write(Settings.PLAYEREXPORTFILE(), arrayListOf("$track"),
StandardOpenOption.CREATE,
Files.newBufferedWriter(Settings.PLAYEREXPORTFILE(),
StandardOpenOption.TRUNCATE_EXISTING,
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING)
StandardOpenOption.CREATE
).close()
Files.write(Settings.PLAYEREXPORTFILE(), track.toString().toByteArray())
logger.debug("""Wrote "$track" into export file (${Settings.PLAYEREXPORTFILE()})""")
}
val total = totalDuration.toMillis()
Expand Down

0 comments on commit 15b9c07

Please sign in to comment.