Commit 0cd32fcd authored by Dmitry Shelepnev's avatar Dmitry Shelepnev
Browse files

New variant transactional working

parent c1eab339
Loading
Loading
Loading
Loading

db.sqlite3-journal

0 → 100644
+175 KiB

File added.

No diff preview for this file type.

+12 −5
Original line number Diff line number Diff line
@@ -3,13 +3,14 @@
import os
import time
import datetime
import opds_catalog.zipf as zipfile
import logging
import re

from django.db import transaction

from opds_catalog import fb2parse, settings, opdsdb
from opds_catalog import inpx_parser
import opds_catalog.zipf as zipfile

class opdsScanner:
    def __init__(self, logger=None):
@@ -75,8 +76,11 @@ class opdsScanner:
        self.zip_file = None
        self.rel_path = None         
              
        opdsdb.set_autocommit(not settings.SINGLE_COMMIT)       
        opdsdb.avail_check_prepare()
        
        if not settings.SINGLE_COMMIT: 
            opdsdb.commit() 
            
        for full_path, dirs, files in os.walk(settings.ROOT_LIB, followlinks=True):
            # Если разрешена обработка inpx, то при нахождении inpx обрабатываем его и прекращаем обработку текущего каталога
            if settings.INPX_ENABLE:
@@ -86,6 +90,8 @@ class opdsScanner:
                    for inpx_file in inpx_files:
                        file = os.path.join(full_path, inpx_file)
                        self.processinpx(inpx_file, full_path, file)
                        if not settings.SINGLE_COMMIT: 
                            opdsdb.commit()                        
                    continue
                
            for name in files:
@@ -97,6 +103,8 @@ class opdsScanner:
                else:
                    file_size=os.path.getsize(file)
                    self.processfile(name,full_path,file,None,0,file_size)
                if not settings.SINGLE_COMMIT: 
                    opdsdb.commit()                    

        #if settings.DELETE_LOGICAL:
        #    self.books_deleted=opdsdb.books_del_logical()
@@ -105,7 +113,6 @@ class opdsScanner:
            
        self.books_deleted=opdsdb.books_del_phisical()
        
        if settings.SINGLE_COMMIT: 
        opdsdb.commit() 
                    
        self.log_stats()
+6 −3
Original line number Diff line number Diff line
@@ -92,9 +92,11 @@ WSGI_APPLICATION = 'sopds.wsgi.application'
#        'USER': 'sopds',
#        'PASSWORD' : 'sopds',
#        'OPTIONS' : {
#            'init_command': "SET default_storage_engine=INNODB",
#            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
#            'init_command': "SET NAMES UTF8"
#            'init_command': """SET default_storage_engine=INNODB, 
#                               SET sql_mode='STRICT_TRANS_TABLES',
#                               SET NAMES UTF8,
#                               SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
#                            """,
#        }
#    }             
#}
@@ -145,6 +147,7 @@ SOPDS_ROOT_LIB = 'W:\\_Downloads\\_Lib.rus.ec - Официальная\\lib.rus.
#SOPDS_ROOT_LIB = '/mnt/SATA1TB-1/КНИГИ/BOOKS/'
#SOPDS_ROOT_LIB = '/mnt/nfs/КНИГИ/BOOKS/'

SOPDS_SINGLE_COMMIT = True
SOPDS_AUTH = True
SOPDS_SCAN_SHED_MIN ='0'
SOPDS_SCAN_SHED_HOUR ='0,12'