Updated document indexing app modules for the new
filename and extension merged field
This commit is contained in:
@@ -127,7 +127,8 @@ def do_rebuild_all_indexes():
|
|||||||
|
|
||||||
# Internal functions
|
# Internal functions
|
||||||
def find_lowest_available_suffix(index_instance, document):
|
def find_lowest_available_suffix(index_instance, document):
|
||||||
index_instance_documents = DocumentRenameCount.objects.filter(index_instance=index_instance).filter(document__file_extension=document.file_extension)
|
# TODO: verify extension's role in query
|
||||||
|
index_instance_documents = DocumentRenameCount.objects.filter(index_instance=index_instance)#.filter(document__file_extension=document.file_extension)
|
||||||
files_list = []
|
files_list = []
|
||||||
for index_instance_document in index_instance_documents:
|
for index_instance_document in index_instance_documents:
|
||||||
files_list.append(assemble_document_filename(index_instance_document.document, index_instance_document.suffix))
|
files_list.append(assemble_document_filename(index_instance_document.document, index_instance_document.suffix))
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ def fs_create_index_directory(index_instance):
|
|||||||
|
|
||||||
def fs_create_document_link(index_instance, document, suffix=0):
|
def fs_create_document_link(index_instance, document, suffix=0):
|
||||||
if FILESERVING_ENABLE:
|
if FILESERVING_ENABLE:
|
||||||
name_part = assemble_document_filename(document, suffix)
|
filename = assemble_document_filename(document.file_filename, suffix)
|
||||||
filename = os.extsep.join([name_part, document.file_extension])
|
|
||||||
filepath = os.path.join(FILESERVING_PATH, get_instance_path(index_instance), filename)
|
filepath = os.path.join(FILESERVING_PATH, get_instance_path(index_instance), filename)
|
||||||
try:
|
try:
|
||||||
os.symlink(document.file.path, filepath)
|
os.symlink(document.file.path, filepath)
|
||||||
@@ -56,11 +55,7 @@ def fs_create_document_link(index_instance, document, suffix=0):
|
|||||||
|
|
||||||
def fs_delete_document_link(index_instance, document, suffix=0):
|
def fs_delete_document_link(index_instance, document, suffix=0):
|
||||||
if FILESERVING_ENABLE:
|
if FILESERVING_ENABLE:
|
||||||
name_part = document.file_filename
|
filename = assemble_document_filename(document.file_filename, suffix)
|
||||||
if suffix:
|
|
||||||
name_part = u'_'.join([name_part, unicode(suffix)])
|
|
||||||
|
|
||||||
filename = os.extsep.join([name_part, document.file_extension])
|
|
||||||
filepath = os.path.join(FILESERVING_PATH, get_instance_path(index_instance), filename)
|
filepath = os.path.join(FILESERVING_PATH, get_instance_path(index_instance), filename)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
from document_indexing.conf.settings import SUFFIX_SEPARATOR
|
from document_indexing.conf.settings import SUFFIX_SEPARATOR
|
||||||
|
|
||||||
|
|
||||||
def assemble_document_filename(document, suffix=0):
|
def assemble_document_filename(filename, suffix=0):
|
||||||
|
'''
|
||||||
|
Split document filename, to attach suffix to the name part then
|
||||||
|
re attacht the extension
|
||||||
|
'''
|
||||||
|
|
||||||
if suffix:
|
if suffix:
|
||||||
return SUFFIX_SEPARATOR.join([document.file_filename, unicode(suffix)])
|
name, extension = filename.split(os.split(os.extsep))
|
||||||
|
return SUFFIX_SEPARATOR.join([name, unicode(suffix), os.extsep, extension])
|
||||||
else:
|
else:
|
||||||
return document.file_filename
|
return file_filename
|
||||||
|
|||||||
Reference in New Issue
Block a user