Ignore document stub from the index mirror. GitLab issue #520. Thanks to TheOneValen @TheOneValen for the report.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
* Make sure all key used as input for the cache key hash are
|
||||
bytes and not unicode. GitLab issue #520. Thanks to TheOneValen
|
||||
@TheOneValen for the report.
|
||||
* Ignore document stub from the index mirror. GitLab issue
|
||||
#520. Thanks to TheOneValen @TheOneValen for the report.
|
||||
|
||||
3.1.6 (2018-10-09)
|
||||
==================
|
||||
|
||||
@@ -13,6 +13,8 @@ Changes
|
||||
* Make sure all key used as input for the cache key hash are
|
||||
bytes and not unicode. GitLab issue #520. Thanks to TheOneValen
|
||||
@TheOneValen for the report.
|
||||
* Ignore document stub from the index mirror. GitLab issue
|
||||
#520. Thanks to TheOneValen @TheOneValen for the report.
|
||||
|
||||
|
||||
Removals
|
||||
|
||||
@@ -80,7 +80,9 @@ class IndexFilesystem(Operations):
|
||||
if access_only:
|
||||
return True
|
||||
else:
|
||||
return Document.objects.get(pk=document_pk)
|
||||
return Document.objects.get(
|
||||
is_stub=False, pk=document_pk
|
||||
)
|
||||
|
||||
for count, part in enumerate(parts[1:]):
|
||||
try:
|
||||
@@ -93,7 +95,9 @@ class IndexFilesystem(Operations):
|
||||
else:
|
||||
try:
|
||||
if node.index_template_node.link_documents:
|
||||
document = node.documents.get(label=part)
|
||||
document = node.documents.get(
|
||||
is_stub=False, label=part
|
||||
)
|
||||
logger.debug(
|
||||
'path %s is a valid file path', path
|
||||
)
|
||||
@@ -203,7 +207,7 @@ class IndexFilesystem(Operations):
|
||||
|
||||
# Documents
|
||||
if node.index_template_node.link_documents:
|
||||
queryset = node.documents.values('label').exclude(
|
||||
queryset = node.documents.filter(is_stub=False).values('label').exclude(
|
||||
label__contains='/'
|
||||
)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from fuse import FuseOSError
|
||||
from django.test import override_settings
|
||||
|
||||
from common.tests import BaseTestCase
|
||||
from documents.models import Document
|
||||
from documents.tests import DocumentTestMixin
|
||||
|
||||
from document_indexing.tests import DocumentIndexingTestMixin
|
||||
@@ -133,3 +134,26 @@ class IndexFilesystemTestCase(DocumentIndexingTestMixin, DocumentTestMixin, Base
|
||||
self.assertEqual(
|
||||
list(index_filesystem.readdir('/', ''))[2:], []
|
||||
)
|
||||
|
||||
def test_ignore_stub_documents(self):
|
||||
self._create_index()
|
||||
|
||||
self.index.node_templates.create(
|
||||
parent=self.index.template_root, expression=TEST_NODE_EXPRESSION,
|
||||
link_documents=True
|
||||
)
|
||||
|
||||
self.document = Document.objects.create(
|
||||
document_type=self.document_type, label='document_stub'
|
||||
)
|
||||
index_filesystem = IndexFilesystem(index_slug=self.index.slug)
|
||||
self.index.rebuild()
|
||||
|
||||
self.assertEqual(
|
||||
list(
|
||||
index_filesystem.readdir(
|
||||
'/{}'.format(TEST_NODE_EXPRESSION), ''
|
||||
)
|
||||
)[2:], []
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user