Skip to content

Commit

Permalink
[EVENTMONITOR LIBRARYSCANNER] Only monitor library path if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh5 committed May 16, 2021
1 parent 2d48ceb commit 0909b98
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion unmanic/libs/eventmonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
OR OTHER DEALINGS IN THE SOFTWARE.
"""
import os
import threading
import time

Expand Down Expand Up @@ -160,7 +161,7 @@ def run(self):
if self.event_observer_thread:
self.stop_event_processor()
# Add delay
time.sleep(1)
time.sleep(.5)

self.stop_event_processor()
self._log("Leaving EventMonitorManager loop...")
Expand All @@ -172,6 +173,10 @@ def start_event_processor(self):
:return:
"""
if not self.event_observer_thread:
library_path = self.settings.get_library_path()
if not os.path.exists(library_path):
time.sleep(.1)
return
self._log("EventMonitorManager spawning EventProcessor thread...")
event_handler = EventHandler(self.data_queues, self.settings)

Expand Down
7 changes: 5 additions & 2 deletions unmanic/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,15 @@ def run(self):

def scheduled_job(self):
self._log("Running full library scan")
self.get_convert_files(self.settings.get_library_path())
self.scan_library_path(self.settings.get_library_path())

def add_path_to_queue(self, pathname):
self.scheduledtasks.put(pathname)

def get_convert_files(self, search_folder):
def scan_library_path(self, search_folder):
if not os.path.exists(search_folder):
self._log("Path does not exist - '{}'".format(search_folder), level="warning")
return
if self.settings.get_debugging():
self._log("Scanning directory - '{}'".format(search_folder), level="debug")
for root, subFolders, files in os.walk(search_folder, followlinks=True):
Expand Down

0 comments on commit 0909b98

Please sign in to comment.