diff --git a/kallithea/lib/auth_modules/auth_internal.py b/kallithea/lib/auth_modules/auth_internal.py --- a/kallithea/lib/auth_modules/auth_internal.py +++ b/kallithea/lib/auth_modules/auth_internal.py @@ -67,6 +67,9 @@ class KallitheaAuthPlugin(auth_modules.K log.warning("userobj:%s extern_type mismatch got:`%s` expected:`%s`", userobj, userobj.extern_type, self.name) return None + if not username: + log.debug('Empty username - skipping...') + return None user_data = { "username": userobj.username, diff --git a/kallithea/lib/auth_modules/auth_pam.py b/kallithea/lib/auth_modules/auth_pam.py --- a/kallithea/lib/auth_modules/auth_pam.py +++ b/kallithea/lib/auth_modules/auth_pam.py @@ -85,6 +85,9 @@ class KallitheaAuthPlugin(auth_modules.K return True def auth(self, userobj, username, password, settings, **kwargs): + if not username: + log.debug('Empty username - skipping...') + return None if username not in _auth_cache: # Need lock here, as PAM authentication is not thread safe _pam_lock.acquire() diff --git a/kallithea/lib/diffs.py b/kallithea/lib/diffs.py --- a/kallithea/lib/diffs.py +++ b/kallithea/lib/diffs.py @@ -160,11 +160,11 @@ class DiffProcessor(object): # has already been split on this: # ^diff[ ]--git [ ]a/(?P.+?)[ ]b/(?P.+?)\n + (?:^old[ ]mode[ ](?P\d+)\n + ^new[ ]mode[ ](?P\d+)(?:\n|$))? (?:^similarity[ ]index[ ](?P\d+)%\n ^rename[ ]from[ ](?P.+)\n ^rename[ ]to[ ](?P.+)(?:\n|$))? - (?:^old[ ]mode[ ](?P\d+)\n - ^new[ ]mode[ ](?P\d+)(?:\n|$))? (?:^new[ ]file[ ]mode[ ](?P.+)(?:\n|$))? (?:^deleted[ ]file[ ]mode[ ](?P.+)(?:\n|$))? (?:^index[ ](?P[0-9A-Fa-f]+) diff --git a/kallithea/lib/indexers/daemon.py b/kallithea/lib/indexers/daemon.py --- a/kallithea/lib/indexers/daemon.py +++ b/kallithea/lib/indexers/daemon.py @@ -177,8 +177,12 @@ class WhooshIndexingDaemon(object): Adding doc to writer this function itself fetches data from the instance of vcs backend """ + try: + node = self.get_node(repo, path, index_rev) + except (ChangesetError, NodeDoesNotExistError): + log.debug("couldn't add doc - %s did not have %r at %s", repo, path, index_rev) + return 0, 0 - node = self.get_node(repo, path, index_rev) indexed = indexed_w_content = 0 if self.is_indexable_node(node): u_content = node.content diff --git a/kallithea/model/db.py b/kallithea/model/db.py --- a/kallithea/model/db.py +++ b/kallithea/model/db.py @@ -2138,7 +2138,13 @@ class CacheInvalidation(Base, BaseModel) return True inv_obj.cache_active = True Session().add(inv_obj) - Session().commit() + try: + Session().commit() + except exc.IntegrityError: + inv_obj = cls.query().filter(cls.cache_key == cache_key).scalar() + if not inv_obj: + raise + # TOCTOU - another thread added the key at the same time; no further action required return False @classmethod diff --git a/kallithea/public/js/base.js b/kallithea/public/js/base.js --- a/kallithea/public/js/base.js +++ b/kallithea/public/js/base.js @@ -1918,7 +1918,7 @@ var prefixFirstSort = function(results, $(document).ready(function(){ $('.diff-collapse-button').click(function(e) { var $button = $(e.currentTarget); - var $target = $('#' + $button.prop('target')); + var $target = $('#' + $button.attr('target')); if($target.hasClass('hidden')){ $target.removeClass('hidden'); $button.html("↑ {0} ↑".format(_TM['Collapse Diff'])); diff --git a/kallithea/tests/fixtures/git_diff_rename_file.diff b/kallithea/tests/fixtures/git_diff_rename_file.diff --- a/kallithea/tests/fixtures/git_diff_rename_file.diff +++ b/kallithea/tests/fixtures/git_diff_rename_file.diff @@ -2,3 +2,9 @@ diff --git a/work-horus.xls b/file.xls similarity index 100% rename from work-horus.xls rename to file.xls +diff --git a/files/var/www/favicon.ico b/files/var/www/favicon.ico/DEFAULT +old mode 100644 +new mode 100755 +similarity index 100% +rename from files/var/www/favicon.ico +rename to files/var/www/favicon.ico/DEFAULT diff --git a/kallithea/tests/models/test_diff_parsers.py b/kallithea/tests/models/test_diff_parsers.py --- a/kallithea/tests/models/test_diff_parsers.py +++ b/kallithea/tests/models/test_diff_parsers.py @@ -133,7 +133,14 @@ DIFF_FIXTURES = { {'added': 0, 'deleted': 0, 'binary': True, - 'ops': {RENAMED_FILENODE: 'file renamed from work-horus.xls to file.xls'}}) + 'ops': {RENAMED_FILENODE: 'file renamed from work-horus.xls to file.xls'}}), + ('files/var/www/favicon.ico/DEFAULT', + 'R', + {'added': 0, + 'binary': True, + 'deleted': 0, + 'ops': {4: 'file renamed from files/var/www/favicon.ico to files/var/www/favicon.ico/DEFAULT', + 6: 'modified file chmod 100644 => 100755'}}) ], 'git_diff_mod_single_binary_file.diff': [ ('US Warszawa.jpg', 'M',