mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-17 16:20:03 +00:00
Handle scan failure correctly
This commit is contained in:
@@ -13,7 +13,7 @@ import {useSnapshot} from "valtio/react";
|
||||
import {scanState} from "Frontend/state/ScanState";
|
||||
import LibraryScanProgress from "Frontend/generated/org/gameyfin/app/libraries/dto/LibraryScanProgress";
|
||||
import {libraryState} from "Frontend/state/LibraryState";
|
||||
import {Target} from "@phosphor-icons/react";
|
||||
import {Target, Warning} from "@phosphor-icons/react";
|
||||
import {timeBetween, timeUntil, toTitleCase} from "Frontend/util/utils";
|
||||
import LibraryScanStatus from "Frontend/generated/org/gameyfin/app/libraries/dto/LibraryScanStatus";
|
||||
import {useEffect, useState} from "react";
|
||||
@@ -77,8 +77,8 @@ export default function ScanProgressPopover() {
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
{scan.status === LibraryScanStatus.IN_PROGRESS ?
|
||||
scan.currentStep.current && scan.currentStep.total ?
|
||||
{scan.status === LibraryScanStatus.IN_PROGRESS &&
|
||||
(scan.currentStep.current && scan.currentStep.total ?
|
||||
<div className="flex flex-col gap-1">
|
||||
<p className="text-default-500">
|
||||
{`${scan.currentStep.description} (${scan.currentStep.current}/${scan.currentStep.total})`}
|
||||
@@ -91,7 +91,9 @@ export default function ScanProgressPopover() {
|
||||
<p className="text-default-500">{scan.currentStep.description}</p>
|
||||
<Progress isIndeterminate size="sm"/>
|
||||
</div>
|
||||
:
|
||||
)
|
||||
}
|
||||
{scan.status === LibraryScanStatus.COMPLETED &&
|
||||
<p>
|
||||
{scan.result?.new} new /
|
||||
{(scan as any).result?.updated != null && `${(scan as any).result.updated} updated / `}
|
||||
@@ -100,6 +102,11 @@ export default function ScanProgressPopover() {
|
||||
(in {timeBetween(scan.startedAt, scan.finishedAt!)})
|
||||
</p>
|
||||
}
|
||||
{scan.status === LibraryScanStatus.FAILED &&
|
||||
<p className="text-danger flex flex-row gap-1"><Warning weight="fill"/>
|
||||
Scan failed (check logs for details)
|
||||
</p>
|
||||
}
|
||||
{scans.length > 1 && index < (scans.length - 1) && <Divider className="my-2"/>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -117,6 +117,7 @@ class LibraryScanService(
|
||||
)
|
||||
emit(progress)
|
||||
|
||||
try {
|
||||
val scanResult = filesystemService.scanLibraryForGamefiles(library)
|
||||
val newPaths = scanResult.newPaths
|
||||
val removedGamePaths = scanResult.removedGamePaths.map { it.toString() }
|
||||
@@ -181,6 +182,12 @@ class LibraryScanService(
|
||||
unmatched = newUnmatchedPaths.size
|
||||
)
|
||||
emit(progress)
|
||||
} catch (e: Exception) {
|
||||
log.error(e) { "Error during quick scan for library ${library.id}: ${e.message}" }
|
||||
progress.status = LibraryScanStatus.FAILED
|
||||
progress.finishedAt = Instant.now()
|
||||
emit(progress)
|
||||
}
|
||||
}
|
||||
|
||||
private fun fullScan(library: Library) {
|
||||
@@ -193,6 +200,7 @@ class LibraryScanService(
|
||||
)
|
||||
emit(progress)
|
||||
|
||||
try {
|
||||
val scanResult = filesystemService.scanLibraryForGamefiles(library)
|
||||
val newPaths = scanResult.newPaths
|
||||
val removedGamePaths = scanResult.removedGamePaths.map { it.toString() }
|
||||
@@ -273,6 +281,13 @@ class LibraryScanService(
|
||||
updated = updatedGames.size
|
||||
)
|
||||
emit(progress)
|
||||
} catch (e: Exception) {
|
||||
log.error(e) { "Error during full scan for library ${library.id}: ${e.message}" }
|
||||
progress.status = LibraryScanStatus.FAILED
|
||||
progress.finishedAt = Instant.now()
|
||||
emit(progress)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
private fun matchNewGames(
|
||||
|
||||
Reference in New Issue
Block a user