#1: Доделал рефакторинг
This commit is contained in:
@@ -37,7 +37,7 @@ class USBVirusScanner {
|
|||||||
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||||
|
|
||||||
fun initialize() {
|
fun initialize() {
|
||||||
println("Инициализация...")
|
println(if (DEBUG) "Инициализация..." else "")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Проверяем доступность gpiod
|
// Проверяем доступность gpiod
|
||||||
@@ -55,7 +55,7 @@ class USBVirusScanner {
|
|||||||
// Запускаем индикацию состояния
|
// Запускаем индикацию состояния
|
||||||
startStateIndication()
|
startStateIndication()
|
||||||
currentState = SystemState.IDLE
|
currentState = SystemState.IDLE
|
||||||
Thread.sleep(500)
|
Thread.sleep(1000)
|
||||||
|
|
||||||
println("Инициализация завершена.")
|
println("Инициализация завершена.")
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ class USBVirusScanner {
|
|||||||
if (parts.size >= 2) {
|
if (parts.size >= 2) {
|
||||||
val mountPoint = parts[1]
|
val mountPoint = parts[1]
|
||||||
|
|
||||||
if ((mountPoint.startsWith("/media") || mountPoint.startsWith("/mnt")) &&
|
if ((mountPoint.startsWith("/media")) &&
|
||||||
File(mountPoint).exists() &&
|
File(mountPoint).exists() &&
|
||||||
devices.none { it.mountPoint == mountPoint }) {
|
devices.none { it.mountPoint == mountPoint }) {
|
||||||
|
|
||||||
@@ -340,8 +340,8 @@ class USBVirusScanner {
|
|||||||
"-r",
|
"-r",
|
||||||
"--stdout",
|
"--stdout",
|
||||||
"--infected",
|
"--infected",
|
||||||
"--max-filesize=1G",
|
"--max-filesize=70M",
|
||||||
"--max-scansize=1G",
|
"--max-scansize=150M",
|
||||||
path
|
path
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -364,6 +364,14 @@ class USBVirusScanner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val syncProccessBuilder = ProcessBuilder("sync")
|
||||||
|
syncProccessBuilder.start()
|
||||||
|
process.waitFor()
|
||||||
|
|
||||||
|
val umountProcessBulder = ProcessBuilder("umount", "/dev/sda", "-f")
|
||||||
|
umountProcessBulder.start()
|
||||||
|
process.waitFor()
|
||||||
|
|
||||||
return ScanResult(
|
return ScanResult(
|
||||||
isInfected = infectedFiles.isNotEmpty(),
|
isInfected = infectedFiles.isNotEmpty(),
|
||||||
infectedFiles = infectedFiles,
|
infectedFiles = infectedFiles,
|
||||||
|
|||||||
Reference in New Issue
Block a user