Skip to content

Commit

Permalink
Merge pull request #26 from cjmanca/in-progress
Browse files Browse the repository at this point in the history
Ignores files with invalid timestamps. #24
  • Loading branch information
cjmanca authored Aug 12, 2022
2 parents 319d5b5 + 55c833d commit 7d7714b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
4 changes: 2 additions & 2 deletions plex-credits-detect/Database/InMemoryFingerprintDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public int ExecuteDBCommand(string cmd, Dictionary<string, object> 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();
Expand Down Expand Up @@ -324,7 +324,7 @@ public SQLResultInfo ExecuteDBQuery(string cmd, Dictionary<string, object> 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();
Expand Down
4 changes: 2 additions & 2 deletions plex-credits-detect/Database/PlexDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public int ExecuteDBCommand(string cmd, Dictionary<string, object> 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();
Expand Down Expand Up @@ -188,7 +188,7 @@ public SQLResultInfo ExecuteDBQuery(string cmd, Dictionary<string, object> 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();
Expand Down
23 changes: 16 additions & 7 deletions plex-credits-detect/Episode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion plex-credits-detect/Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 7d7714b

Please sign in to comment.