From ad0eb94e63e93f58e4328a1785220a402209c317 Mon Sep 17 00:00:00 2001 From: ShyPike Date: Mon, 9 Apr 2012 20:24:43 +0200 Subject: [PATCH] Fix detection of retry-able history entries for case-insensitive file systems. --- sabnzbd/api.py | 5 +++-- sabnzbd/misc.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sabnzbd/api.py b/sabnzbd/api.py index 5b6440a..77966ce 100644 --- a/sabnzbd/api.py +++ b/sabnzbd/api.py @@ -51,7 +51,8 @@ from sabnzbd.utils.rsslib import RSS, Item from sabnzbd.utils.json import JsonWriter from sabnzbd.utils.pathbrowser import folders_at_path from sabnzbd.misc import loadavg, to_units, diskfree, disktotal, get_ext, \ - get_filename, int_conv, globber, time_format, remove_all + get_filename, int_conv, globber, time_format, remove_all, \ + starts_with_path from sabnzbd.encoding import xml_name, unicoder, special_fixer, platform_encode from sabnzbd.postproc import PostProcessor from sabnzbd.articlecache import ArticleCache @@ -1698,7 +1699,7 @@ def build_history(start=None, limit=None, verbose=False, verbose_list=None, sear item['retry'] = int(bool(item.get('status') == 'Failed' and \ path and \ path not in retry_folders and \ - path.startswith(cfg.download_dir.get_path()) and \ + starts_with_path(path, cfg.download_dir.get_path()) and \ os.path.exists(path)) and \ not bool(globber(os.path.join(path, JOB_ADMIN), 'SABnzbd_n*')) \ ) diff --git a/sabnzbd/misc.py b/sabnzbd/misc.py index 9aa0f3c..4986e83 100644 --- a/sabnzbd/misc.py +++ b/sabnzbd/misc.py @@ -1260,3 +1260,12 @@ def match_str(text, matches): if match in text: return match return None + +def starts_with_path(path, prefix): + ''' Return True if 'path' starts with 'prefix', + considering case-sensitivity of filesystem + ''' + if sabnzbd.WIN32 or sabnzbd.DARWIN: + return path.lower().startswith(prefix.lower()) + else: + return path.startswith(prefix)