# Path: sunflower/plugin_base/monitor.py
# class MonitorSignals:
# 	CHANGED = 0  # file changed
# 	CHANGES_DONE = 1  # a hint that this was probably the last change in a set
# 	DELETED = 2  # file was deleted
# 	CREATED = 3  # file was created
# 	ATTRIBUTE_CHANGED = 4  # attribute was changed
# 	PRE_UNMOUNT = 5  # location will soon be unmounted
# 	UNMOUNTED = 6  # location was unmounted
# 	MOVED = 7  # file was moved
# 	EMBLEM_CHANGED = 8  # list of emblems has changed
# 	DIRECTORY_SIZE_CHANGED = 9  # calculated directory size has changed
# 	DIRECTORY_SIZE_STOPPED = 10  # directory size calculation has finished


import os
from threading import Thread, Event, Lock
from sunflower.plugin_base.monitor import MonitorSignals
		self._counts = {}
		self._lock = Lock()

	def __update_totals(self, parent_id, path, total_count, total_size):
		"""Update global dictionaries with new statistics."""
		key = (parent_id, path)

		self._lock.acquire()
		self._sizes[key] = total_size
		self._counts[key] = total_count
		self._lock.release()

	def __calculate_usage(self, parent_id, monitor_queue, provider, path, stop_event):
		"""Threaded method used for calculating disk usage."""
		total_count = 0
		total_size = 0
		scan_list = []

		# add initial path for scanning
		scan_list.append(path)

		# loop through all paths and calculate
		while not stop_event.is_set():
			# get path for scanning
			try:
				scan_path = scan_list.pop(0)

			except IndexError:
				# no more directories to traverse
				self.__update_totals(parent_id, path, total_count, total_size)

# Path: sunflower/plugin_base/monitor.py
# class MonitorSignals:
# 	CHANGED = 0  # file changed
# 	CHANGES_DONE = 1  # a hint that this was probably the last change in a set
# 	DELETED = 2  # file was deleted
# 	CREATED = 3  # file was created
# 	ATTRIBUTE_CHANGED = 4  # attribute was changed
# 	PRE_UNMOUNT = 5  # location will soon be unmounted
# 	UNMOUNTED = 6  # location was unmounted
# 	MOVED = 7  # file was moved
# 	EMBLEM_CHANGED = 8  # list of emblems has changed
# 	DIRECTORY_SIZE_CHANGED = 9  # calculated directory size has changed
# 	DIRECTORY_SIZE_STOPPED = 10  # directory size calculation has finished


# Path: sunflower/tools/disk_usage.py
import os
from threading import Thread, Event, Lock
from sunflower.plugin_base.monitor import MonitorSignals

		self._counts = {}
		self._lock = Lock()

	def __update_totals(self, parent_id, path, total_count, total_size):
		"""Update global dictionaries with new statistics."""
		key = (parent_id, path)

		self._lock.acquire()
		self._sizes[key] = total_size
		self._counts[key] = total_count
		self._lock.release()

	def __calculate_usage(self, parent_id, monitor_queue, provider, path, stop_event):
		"""Threaded method used for calculating disk usage."""
		total_count = 0
		total_size = 0
		scan_list = []

		# add initial path for scanning
		scan_list.append(path)

		# loop through all paths and calculate
		while not stop_event.is_set():
			# get path for scanning
			try:
				scan_path = scan_list.pop(0)

			except IndexError:
				# no more directories to traverse
				self.__update_totals(parent_id, path, total_count, total_size)

				monitor_queue.put((MonitorSignals.DIRECTORY_SIZE_CHANGED, path, None), False)