mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-17 00:30:04 +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 {scanState} from "Frontend/state/ScanState";
|
||||||
import LibraryScanProgress from "Frontend/generated/org/gameyfin/app/libraries/dto/LibraryScanProgress";
|
import LibraryScanProgress from "Frontend/generated/org/gameyfin/app/libraries/dto/LibraryScanProgress";
|
||||||
import {libraryState} from "Frontend/state/LibraryState";
|
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 {timeBetween, timeUntil, toTitleCase} from "Frontend/util/utils";
|
||||||
import LibraryScanStatus from "Frontend/generated/org/gameyfin/app/libraries/dto/LibraryScanStatus";
|
import LibraryScanStatus from "Frontend/generated/org/gameyfin/app/libraries/dto/LibraryScanStatus";
|
||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
@@ -77,8 +77,8 @@ export default function ScanProgressPopover() {
|
|||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
{scan.status === LibraryScanStatus.IN_PROGRESS ?
|
{scan.status === LibraryScanStatus.IN_PROGRESS &&
|
||||||
scan.currentStep.current && scan.currentStep.total ?
|
(scan.currentStep.current && scan.currentStep.total ?
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<p className="text-default-500">
|
<p className="text-default-500">
|
||||||
{`${scan.currentStep.description} (${scan.currentStep.current}/${scan.currentStep.total})`}
|
{`${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>
|
<p className="text-default-500">{scan.currentStep.description}</p>
|
||||||
<Progress isIndeterminate size="sm"/>
|
<Progress isIndeterminate size="sm"/>
|
||||||
</div>
|
</div>
|
||||||
:
|
)
|
||||||
|
}
|
||||||
|
{scan.status === LibraryScanStatus.COMPLETED &&
|
||||||
<p>
|
<p>
|
||||||
{scan.result?.new} new /
|
{scan.result?.new} new /
|
||||||
{(scan as any).result?.updated != null && `${(scan as any).result.updated} updated / `}
|
{(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!)})
|
(in {timeBetween(scan.startedAt, scan.finishedAt!)})
|
||||||
</p>
|
</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"/>}
|
{scans.length > 1 && index < (scans.length - 1) && <Divider className="my-2"/>}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ class LibraryScanService(
|
|||||||
)
|
)
|
||||||
emit(progress)
|
emit(progress)
|
||||||
|
|
||||||
|
try {
|
||||||
val scanResult = filesystemService.scanLibraryForGamefiles(library)
|
val scanResult = filesystemService.scanLibraryForGamefiles(library)
|
||||||
val newPaths = scanResult.newPaths
|
val newPaths = scanResult.newPaths
|
||||||
val removedGamePaths = scanResult.removedGamePaths.map { it.toString() }
|
val removedGamePaths = scanResult.removedGamePaths.map { it.toString() }
|
||||||
@@ -181,6 +182,12 @@ class LibraryScanService(
|
|||||||
unmatched = newUnmatchedPaths.size
|
unmatched = newUnmatchedPaths.size
|
||||||
)
|
)
|
||||||
emit(progress)
|
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) {
|
private fun fullScan(library: Library) {
|
||||||
@@ -193,6 +200,7 @@ class LibraryScanService(
|
|||||||
)
|
)
|
||||||
emit(progress)
|
emit(progress)
|
||||||
|
|
||||||
|
try {
|
||||||
val scanResult = filesystemService.scanLibraryForGamefiles(library)
|
val scanResult = filesystemService.scanLibraryForGamefiles(library)
|
||||||
val newPaths = scanResult.newPaths
|
val newPaths = scanResult.newPaths
|
||||||
val removedGamePaths = scanResult.removedGamePaths.map { it.toString() }
|
val removedGamePaths = scanResult.removedGamePaths.map { it.toString() }
|
||||||
@@ -273,6 +281,13 @@ class LibraryScanService(
|
|||||||
updated = updatedGames.size
|
updated = updatedGames.size
|
||||||
)
|
)
|
||||||
emit(progress)
|
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(
|
private fun matchNewGames(
|
||||||
|
|||||||
Reference in New Issue
Block a user