Skip to content

Commit

Permalink
#59 Remove ":" of temporary file names
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jul 2, 2018
1 parent 8974448 commit 1bc7c21
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/org/elastic4play/services/TempSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,25 @@ class TempSrv @Inject() (
case t: Throwable logger.warn(s"Fail to remove temporary files ($directory) : $t")
}

private def requestTempDir(requestId: String): Path = {
tempDir.resolve(requestId.replaceAllLiterally(":", "_"))
}

def newTemporaryFile(prefix: String, suffix: String)(implicit authContext: AuthContext): Path = {
val td = tempDir.resolve(authContext.requestId)
val td = requestTempDir(authContext.requestId)
if (!Files.exists(td))
Files.createDirectories(td)
Files.createTempFile(tempDir.resolve(authContext.requestId), prefix, suffix)
}

def releaseTemporaryFiles()(implicit authContext: AuthContext): Unit = {
releaseTemporaryFiles(authContext.requestId)
Files.createTempFile(td, prefix, suffix)
}

def releaseTemporaryFiles(request: RequestHeader): Unit = {
releaseTemporaryFiles(Instance.getRequestId(request))
}

def releaseTemporaryFiles(requestId: String): Unit = {
val d = tempDir.resolve(requestId)
if (Files.exists(d))
delete(d)
val td = requestTempDir(requestId)
if (Files.exists(td))
delete(td)
}
}

Expand Down

0 comments on commit 1bc7c21

Please sign in to comment.