This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-198
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-198 by this push:
new 824fae8 Update NCCli.scala
824fae8 is described below
commit 824fae8ccc525eaefbc046d09017b819b224bb2a
Author: Aaron Radzinski <[email protected]>
AuthorDate: Thu Dec 17 19:06:17 2020 -0800
Update NCCli.scala
---
.../apache/nlpcraft/model/tools/cmdline/NCCli.scala | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
index 5b9bcc3..3531d3a 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
@@ -405,7 +405,6 @@ object NCCli extends App {
// Store mapping file between PID and timestamp (once we have
server PID).
// Note that the same timestamp is used in server log file.
ignoring(classOf[IOException]) {
- // TODO: These don't get deleted?
new File(SystemUtils.getUserHome,
s".nlpcraft/.pid_${srvPid}_tstamp_$logTstamp").createNewFile()
}
@@ -546,6 +545,21 @@ object NCCli extends App {
throw new IllegalStateException(s"Classpath not found:
${c(path)}")
/**
+ *
+ */
+ private def cleanUpTempFiles(): Unit = {
+ val tstamp = currentTime - 1000 * 60 * 60 * 24 * 2 // 2 days ago.
+
+ for (file <- new File(SystemUtils.getUserHome,
".nlpcraft").listFiles())
+ if (file.lastModified() < tstamp) {
+ val name = file.getName
+
+ if (name.startsWith("server_log") ||
name.startsWith("server_log") || name.startsWith(".pid_"))
+ file.delete()
+ }
+ }
+
+ /**
* @param cmd Command descriptor.
* @param args Arguments, if any, for this command.
* @param repl Whether or not running from REPL.
@@ -2987,6 +3001,8 @@ object NCCli extends App {
sys.exit(exitStatus)
}
+ cleanUpTempFiles()
+
// Boot up.
boot(args)
}