Commit a489d3b7 by Amelin Konstantin

remove output split, change sorting input - zip lastmodified

parent 6e748efd
......@@ -33,12 +33,12 @@ object Main {
var logString = ""
val paths = Files.list(Paths.get(args(0)))
.filter {
p => !Files.isDirectory(p)
}
.iterator
.asScala
.toStream
.filter {
p => !Files.isDirectory(p)
}
val start = LocalDateTime.now.toString.replace(":", ".")
......@@ -48,22 +48,14 @@ object Main {
val sourceNameNotValidated = s"${args(0)}/${start}_not_validated"
val sourceNotValidated = Try { Files.createDirectory(Paths.get(sourceNameNotValidated)) }
val sourceNameError = s"${args(0)}/${start}_error"
val sourceNameError = s"${args(0)}/error_$start"
val sourceError = Try { Files.createDirectory(Paths.get(sourceNameError)) }
val outputNameValidated = s"${args(1)}/${start}_validated"
val outputValidated = Try { Files.createDirectory(Paths.get(outputNameValidated)) }
val outputNameNotValidated = s"${args(1)}/${start}_not_validated"
val outputNotValidated = Try { Files.createDirectory(Paths.get(outputNameNotValidated)) }
val createDirRes = for {
sv <- sourceValidated
snv <- sourceNotValidated
se <- sourceError
ov <- outputValidated
onv <- outputNotValidated
} yield onv
} yield se
createDirRes match {
case Success(_) =>
......@@ -88,7 +80,7 @@ object Main {
FileEntry(
s"${name}_${e.getName}",
//e.getName,
e.getLastModifiedTime,
Files.getLastModifiedTime(p),
Some(zip.getInputStream(e)),
zip.getInputStream(e),
Some(zip),
......@@ -143,23 +135,18 @@ object Main {
rtsXmlValid,
p)
} match {
case Success((oXml, ti)) if ti.contains("isn`t wellformed or invalid") =>
XML.save(
Paths.get(outputNameNotValidated, s"converted_${f.name}").toString,
oXml,
xmlDecl = true
)
logString += s"'$now'\n$ti"
Files.copy(f.streamMove, Paths.get(sourceNameNotValidated, f.name))
case Success((oXml, ti)) =>
XML.save(
Paths.get(outputNameValidated, s"converted_${f.name}").toString,
Paths.get(args(1), s"converted_${f.name}").toString,
oXml,
xmlDecl = true
)
logString += s"'$now'\n$ti"
Files.copy(f.streamMove, Paths.get(sourceNameValidated, f.name))
if (ti.contains("isn`t wellformed or invalid"))
Files.copy(f.streamMove, Paths.get(sourceNameNotValidated, f.name))
else
Files.copy(f.streamMove, Paths.get(sourceNameValidated, f.name))
case Failure(ex) =>
logString += s"'$now'\nImpossible to convert '${f.name}': ${ex.toString}\n\n"
......@@ -199,8 +186,6 @@ object Main {
if (Files.list(sourceNotValidated.get).toArray.isEmpty) Files.delete(sourceNotValidated.get)
if (Files.list(sourceError.get).toArray.isEmpty) Files.delete(sourceError.get)
if (Files.list(outputValidated.get).toArray.isEmpty) Files.delete(outputValidated.get)
if (Files.list(outputNotValidated.get).toArray.isEmpty) Files.delete(outputNotValidated.get)
} match {
case Success(_) => println(s"Converting has been finished. $logFileName located in ${args(0)}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment