Skip to content

Commit

Permalink
corrected Folder Watch loop + checks for #20: the intent here is very…
Browse files Browse the repository at this point in the history
… similar to the code done previously for #17; we just want to add a tiny batch of PDF files from the Watch folder, irrespective of the amount of files waiting there to be added.
  • Loading branch information
GerHobbelt committed Aug 2, 2019
1 parent bd65680 commit da3f853
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
19 changes: 13 additions & 6 deletions Qiqqa/DocumentLibrary/FolderWatching/FolderWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,6 @@ public void TaskDaemonEntryPoint(Daemon daemon)
break;
}

if (DateTime.UtcNow.Subtract(index_processing_start_time).TotalSeconds > MAX_SECONDS_PER_ITERATION)
{
Logging.Info("FolderWatcher: Breaking out of outer processing loop due to MAX_SECONDS_PER_ITERATION: {0} seconds consumed", DateTime.UtcNow.Subtract(index_processing_start_time).TotalSeconds);
break;
}

if (!daemon.StillRunning)
{
Logging.Debug("FolderWatcher: Breaking out of outer processing loop due to daemon termination");
Expand Down Expand Up @@ -189,6 +183,13 @@ public void TaskDaemonEntryPoint(Daemon daemon)
break;
}

if (DateTime.UtcNow.Subtract(index_processing_start_time).TotalSeconds > MAX_SECONDS_PER_ITERATION)
{
Logging.Info("FolderWatcher: Breaking out of inner processing loop due to MAX_SECONDS_PER_ITERATION: {0} seconds consumed", DateTime.UtcNow.Subtract(index_processing_start_time).TotalSeconds);
folder_contents_has_changed = true;
break;
}

// If we already have this file in the "cache since we started", skip it
if (folder_watcher_manager.HaveProcessedFile(filename))
{
Expand Down Expand Up @@ -239,7 +240,13 @@ public void TaskDaemonEntryPoint(Daemon daemon)

// Get the library to import all these new files
ImportingIntoLibrary.AddNewPDFDocumentsToLibraryWithMetadata_ASYNCHRONOUS(library, true, true, filename_with_metadata_imports.ToArray());

Logging.Debug("FolderWatcher End-Of-Round");

daemon.Sleep(3 * 1000);
}

Logging.Debug("FolderWatcher END");
}

bool IsFileLocked(string filename)
Expand Down
1 change: 0 additions & 1 deletion Qiqqa/DocumentLibrary/ImportingIntoLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public static PDFDocument AddNewPDFDocumentsToLibraryWithMetadata_SYNCHRONOUS(Li
}
last_added_pdf_document = pdf_document;
}

catch (Exception ex)
{
Logging.Warn(ex, "There was a problem adding a document to the library:\n{0}", filename_with_metadata_import);
Expand Down

0 comments on commit da3f853

Please sign in to comment.