Skip to content

Commit

Permalink
fix: add catch in try get method
Browse files Browse the repository at this point in the history
- Don't throw in the try get method for retrieving the file id.
  • Loading branch information
revam committed Jul 14, 2024
1 parent 67edfa7 commit 09d4ae0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Shokofin/API/ShokoAPIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,15 @@ public bool TryGetFileIdForPath(string path, [NotNullWhen(true)] out string? fil

// Slow path; getting the show from cache or remote and finding the default season's id.
Logger.LogDebug("Trying to find file id using the slow path. (Path={FullPath})", path);
if (GetFileInfoByPath(path).ConfigureAwait(false).GetAwaiter().GetResult() is { } tuple && tuple.Item1 is not null) {
var (fileInfo, _, _) = tuple;
fileId = fileInfo.Id;
return true;
try {
if (GetFileInfoByPath(path).ConfigureAwait(false).GetAwaiter().GetResult() is { } tuple && tuple.Item1 is not null) {
var (fileInfo, _, _) = tuple;
fileId = fileInfo.Id;
return true;
}
}
catch (Exception ex) {
Logger.LogError(ex, "Encountered an error while trying to lookup the file id for {Path}", path);
}

fileId = null;
Expand Down

0 comments on commit 09d4ae0

Please sign in to comment.