This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a commit to branch NLPCRAFT-483
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-483 by this push:
     new 0a87440  WIP.
0a87440 is described below

commit 0a87440be1216c10e7affd35111774ed96c31775
Author: Sergey Kamov <[email protected]>
AuthorDate: Wed Mar 2 18:53:22 2022 +0300

    WIP.
---
 .../org/apache/nlpcraft/internal/util/NCResourceReader.scala  | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/util/NCResourceReader.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/util/NCResourceReader.scala
index 5dca009..39d4b53 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/util/NCResourceReader.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/util/NCResourceReader.scala
@@ -144,7 +144,7 @@ object NCResourceReader extends LazyLogging:
         val md5 = readMd5(MD5_FILE_URL)
         var f = new File(path)
 
-        def process(f: File): File =
+        def validateOrDownload(f: File): File =
             if isValid(f, md5) then
                 logger.info(s"File found: ${f.getAbsolutePath}")
                 f
@@ -154,26 +154,25 @@ object NCResourceReader extends LazyLogging:
 
         // Path.
         if NCUtils.isFile(f) then
-            process(f)
+            validateOrDownload(f)
         else
             // Path in default folder.
             f = new File(DFLT_DIR, path)
 
             if NCUtils.isFile(f) then
-                process(f)
+                validateOrDownload(f)
             else
                 // Resource.
                 if NCUtils.isResource(path) then
                     getClass.getClassLoader.getResourceAsStream(path) match
                         case in if in != null =>
                             Using.resource(new FileOutputStream(f)) { out => 
IOUtils.copy(in, out) }
-
-                            process(f)
+                            validateOrDownload(f)
                         case _ => E(s"Resource not found: $path")
                 // URL.
                 else if NCUtils.isUrl(path) then
                     IOUtils.copy(new URL(path), f)
-                    process(f)
+                    validateOrDownload(f)
                 else
                     // Download.
                     download(path, f.getAbsolutePath, md5)

Reply via email to