Deleting Apps/Repos: App matching query does not exist.
Sometimes, when deleting an app or a repo, Repomaker fails with the error App matching query does not exist
.
This is because Repomaker tries to delete an app icon in a post delete apk pointer handler but the app does not exist anymore.
@grote You therefore included the check if self.app:
but curiously this is exactly the point where it fails. I couldn't come up with a fix. As a workaround, I'm removing the check to be able to delete apps and repos.
Git blame of the affected line: https://gitlab.com/fdroid/repomaker/blame/master/repomaker/models/apkpointer.py#L133
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/4/app/10/delete/
Django Version: 1.11.4
Python Version: 3.5.4
Installed Applications:
['repomaker.apps.RepoMakerConfig',
'sass_processor',
'background_task',
'hvad',
'tinymce',
'django_js_reverse',
'django.forms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.contrib.sites',
'allauth.account']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/home/dev/.local/lib/python3.5/site-packages/django/db/models/fields/related_descriptors.py" in __get__
178. rel_obj = getattr(instance, self.cache_name)
During handling of the above exception ('ApkPointer' object has no attribute '_app_cache'), another exception occurred:
File "/home/dev/.local/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/home/dev/.local/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/home/dev/.local/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/dev/.local/lib/python3.5/site-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)
File "/home/dev/Work/F-Droid/repomaker/repomaker/views/__init__.py" in dispatch
217. return super().dispatch(request, *args, **kwargs)
File "/home/dev/.local/lib/python3.5/site-packages/django/contrib/auth/mixins.py" in dispatch
56. return super(LoginRequiredMixin, self).dispatch(request, *args, **kwargs)
File "/home/dev/.local/lib/python3.5/site-packages/django/contrib/auth/mixins.py" in dispatch
116. return super(UserPassesTestMixin, self).dispatch(request, *args, **kwargs)
File "/home/dev/.local/lib/python3.5/site-packages/django/views/generic/base.py" in dispatch
88. return handler(request, *args, **kwargs)
File "/home/dev/.local/lib/python3.5/site-packages/django/views/generic/edit.py" in post
269. return self.delete(request, *args, **kwargs)
File "/home/dev/.local/lib/python3.5/site-packages/django/views/generic/edit.py" in delete
264. self.object.delete()
File "/home/dev/.local/lib/python3.5/site-packages/django/db/models/base.py" in delete
973. return collector.delete()
File "/home/dev/.local/lib/python3.5/site-packages/django/db/models/deletion.py" in delete
308. sender=model, instance=obj, using=self.using
File "/home/dev/.local/lib/python3.5/site-packages/django/dispatch/dispatcher.py" in send
193. for receiver in self._live_receivers(sender)
File "/home/dev/.local/lib/python3.5/site-packages/django/dispatch/dispatcher.py" in <listcomp>
193. for receiver in self._live_receivers(sender)
File "/home/dev/Work/F-Droid/repomaker/repomaker/models/apkpointer.py" in apk_pointer_post_delete_handler
163. apk_pointer.delete_app_icons_from_repo()
File "/home/dev/Work/F-Droid/repomaker/repomaker/models/apkpointer.py" in delete_app_icons_from_repo
133. if self.app:
File "/home/dev/.local/lib/python3.5/site-packages/django/db/models/fields/related_descriptors.py" in __get__
184. rel_obj = self.get_object(instance)
File "/home/dev/.local/lib/python3.5/site-packages/django/db/models/fields/related_descriptors.py" in get_object
159. return qs.get(self.field.get_reverse_related_filter(instance))
File "/home/dev/.local/lib/python3.5/site-packages/django/db/models/query.py" in get
380. self.model._meta.object_name
Exception Type: DoesNotExist at /4/app/10/delete/
Exception Value: App matching query does not exist.