diff --git a/plex-credits-detect/Database/InMemoryFingerprintDatabase.cs b/plex-credits-detect/Database/InMemoryFingerprintDatabase.cs index 27abf88..ef44d24 100644 --- a/plex-credits-detect/Database/InMemoryFingerprintDatabase.cs +++ b/plex-credits-detect/Database/InMemoryFingerprintDatabase.cs @@ -254,7 +254,7 @@ public int ExecuteDBCommand(string cmd, Dictionary p = null, int } catch (SQLiteException ex) { - if (count >= 2) + if (count >= 2 + recursionCount) { Console.WriteLine($"plex-credits-detect Database ExecuteDBCommand Database has been locked for a long time. Attempting to re-connect."); CloseDatabase(); @@ -324,7 +324,7 @@ public SQLResultInfo ExecuteDBQuery(string cmd, Dictionary p = n } catch (SQLiteException ex) { - if (count >= 2) + if (count >= 2 + recursionCount) { Console.WriteLine($"plex-credits-detect Database ExecuteDBCommand Database has been locked for a long time. Attempting to re-connect."); CloseDatabase(); diff --git a/plex-credits-detect/Database/PlexDB.cs b/plex-credits-detect/Database/PlexDB.cs index efc55d3..66eed23 100644 --- a/plex-credits-detect/Database/PlexDB.cs +++ b/plex-credits-detect/Database/PlexDB.cs @@ -128,7 +128,7 @@ public int ExecuteDBCommand(string cmd, Dictionary p = null, int } catch (SQLiteException e) { - if (count >= 2) + if (count >= 2 + recursionCount) { Console.WriteLine($"PlexDB ExecuteDBCommand Database has been locked for a long time. Attempting to re-connect."); CloseDatabase(); @@ -188,7 +188,7 @@ public SQLResultInfo ExecuteDBQuery(string cmd, Dictionary p = n } catch (SQLiteException e) { - if (count >= 2) + if (count >= 2 + recursionCount) { Console.WriteLine($"PlexDB ExecuteDBCommand Database has been locked for a long time. Attempting to re-connect."); CloseDatabase(); diff --git a/plex-credits-detect/Episode.cs b/plex-credits-detect/Episode.cs index c562646..4e5bcdf 100644 --- a/plex-credits-detect/Episode.cs +++ b/plex-credits-detect/Episode.cs @@ -298,9 +298,10 @@ public Episode(string path) ParseInfoFromPath(path); } - void ParseInfoFromPath(string path) + void ParseInfoFromPath(string pPath) { - path = Program.getRelativePath(path); + + string path = Program.getRelativePath(pPath); Exists = false; id = path; @@ -314,12 +315,20 @@ void ParseInfoFromPath(string path) if (fi.Exists) { - Exists = true; - path = fi.FullName; - LastWriteTimeUtcOnDisk = fi.LastWriteTimeUtc; - FileSizeOnDisk = fi.Length; + try + { + Exists = true; + LastWriteTimeUtcOnDisk = fi.LastWriteTimeUtc; + FileSizeOnDisk = fi.Length; + path = fi.FullName; - break; + break; + } + catch (Exception e) // Issue #24: a file that exists but with an invalid LastWriteTimeUtc. Possible filesystem corruption, ignore the offending file. + { + Exists = false; + Console.WriteLine("File found with an invalid LastWriteTimeUtc index. Ignoring: " + p); + } } } diff --git a/plex-credits-detect/Scanner.cs b/plex-credits-detect/Scanner.cs index a7d1101..545088f 100644 --- a/plex-credits-detect/Scanner.cs +++ b/plex-credits-detect/Scanner.cs @@ -1317,7 +1317,10 @@ public void CheckForPlexChangedDirectories() { data = plexDB.GetRecentlyModifiedDirectories(db.lastPlexDirectoryChanged); - Console.WriteLine($"Found changed directories: {data.Count} \n"); + if (data.Count > 0) + { + Console.WriteLine($"Found changed directories: {data.Count} \n"); + } foreach (var item in data) {