Skip to content
Snippets Groups Projects
Commit 227a0070 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #9607: logging, minor fix

parent 752bb0f5
No related branches found
No related tags found
No related merge requests found
......@@ -123,7 +123,7 @@ class CacheManager:
if du_result['found']:
if not path in path_cache or path_cache[path]['disk_usage'] != du_result['disk_usage']:
logger.debug('updating cache entry: %s', du_result)
logger.info('updating cache entry: %s', du_result)
path_cache[path] = du_result
self._sendDiskUsageChangedNotification(path, du_result['disk_usage'], otdb_id)
......@@ -161,7 +161,7 @@ class CacheManager:
with self._cacheLock:
path_cache = self._cache['path_du_results']
if directory not in path_cache:
if not directory in path_cache:
logger.info('tree scan: adding \'%s\' with empty disk_usage to cache which will be du\'ed later', directory)
empty_du_result = {'found': True, 'disk_usage': None, 'path': directory, 'name': directory.split('/')[-1]}
self._updateCache(empty_du_result)
......@@ -211,6 +211,10 @@ class CacheManager:
if depth1 == 2 or depth2 == 2:
if depth1 == 2 and depth2 == 2:
if not entry1['disk_usage']:
return -1
if not entry2['disk_usage']:
return 1
if entry1['cache_timestamp'] < entry2['cache_timestamp']:
return -1
if entry1['cache_timestamp'] > entry2['cache_timestamp']:
......@@ -242,7 +246,7 @@ class CacheManager:
logger.info('examining old entry %s/%s in cache: %s', i, len(old_entries), path)
result = du_getDiskUsageForPath(path)
if result['found']:
logger.info('updating old entry in cache: %s', result)
logger.debug('trying to update old entry in cache: %s', result)
self._updateCache(result)
except Exception as e:
logger.error(str(e))
......@@ -253,7 +257,7 @@ class CacheManager:
if datetime.datetime.utcnow() - cacheUpdateStart > datetime.timedelta(minutes=5):
# break out of cache update loop if full update takes more than 5min
# next loop we'll start with the oldest cache entries again
logger.info('skipping remaining old cache entries updates, they will be updated next time')
logger.info('skipping remaining %s old cache entries updates, they will be updated next time', len(old_entries)-i)
break
for i in range(60):
......
......@@ -31,16 +31,15 @@ import logging
logger = logging.getLogger(__name__)
def updateTaskStorageDetails(tasks, sqrpc):
if not tasks:
return
def applyDefaults(task):
'''apply sane default values for a task'''
task['disk_usage'] = None
task['disk_usage_readable'] = None
try:
_ = (t for t in tasks)
except TypeError:
# make single task instance a list
tasks = [tasks]
tasks = tasks if isinstance(tasks, list) else [tasks]
for task in tasks:
applyDefaults(task)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment