View Full Version : sqlite samba lock


rootto
09-26-2009, 12:08 PM
Hi,

I'm tying to use calibre (0.4.143) using a samba share, but I receive an error from sqlite. I read that sqlite has problem with network shares: is there any way to keep all the *.db in my home directory and use the samba share only to store the library. I've modified the property database_path in the file .config/globay.py in order to point to my home directory. The library1.db is not created, instead the file metadata.db is created in the library directory (if I specify a local directory the file is populated with the db, if I use the share the file has only an 'S'). Any idea on how to solve the problem?

Thanks

Nicola

itimpi
09-26-2009, 12:54 PM
Yes - you can have tight control over where aoll the Caliber files are located using a combination of Environment Variables and runtime switches. I use the following batch file on Windows:
@echo OFF
REM Batch File to start a Calibre configuration on Windows
REM giving explicit control of the location of:
REM - Calibe Program Files
REM - Calibre Library Files
REM - Calibre Config Files
REM - Calibre Metadata database
REM By setting the paths correctly it can be used to run:
REM - A "portable calibre" off a USB stick.
REM - A network installation with local metadata database
REM (for performance) and books stored on a network share

CD CalibreConfig
SET CALIBRE_CONFIG_DIRECTORY=%cd%
CD ..
CD CalibreLibrary
rem SET CALIBRE_LIBRARY_DIRECTORY=%cd%
SET CALIBRE_LIBRARY_DIRECTORY=U:\eBooks\CalibreLibrary
CD ..
CD Calibre
SET CALIBRE_OVERRIDE_DATABASE_PATH=P:\CalibreLibrary\m etadata.db

echo CD=%cd%
echo CONFIG=%CALIBRE_CONFIG_DIRECTORY%
echo LIBRARY=%CALIBRE_LIBRARY_DIRECTORY%
echo DATABASE=%CALIBRE_OVERRIDE_DATABASE_PATH%
pause

START /belownormal Calibre --with-library %CALIBRE_LIBRARY_DIRECTORY%

This setup is running with a network share for the book files (U:) and a local (P:) metadata.db file. You will note I also specify where the Calibre Config information and Program Files are located as I do not use default locations for either. The other point is starting Calibre at BelowNormal priority as this keeps my system responsive without affecting Calibre performance significantly. You should be able to amend it to suit your particular requirements.

If you are not using Windows it should be easy enough to translate it to the equivalent on your system.

rootto
09-27-2009, 08:03 AM
Thanks for your script. I forgot to say that I'm running ubuntu. This is the converted script:


#!/bin/dash

# Batch File to start a Calibre configuration on Windows
# giving explicit control of the location of:
# - Calibe Program Files
# - Calibre Library Files
# - Calibre Config Files
# - Calibre Metadata database
# By setting the paths correctly it can be used to run:
# - A "portable calibre" off a USB stick.
# - A network installation with local metadata database
# (for performance) and books stored on a network share

CalibreConfig=/home/`whoami`/.config/calibre
LIBRARY_DIR='/media/Nicola/Ebooks/'

export CALIBRE_CONFIG_DIRECTORY=$CalibreConfig
export CALIBRE_LIBRARY_DIRECTORY=$LIBRARY_DIR
export CALIBRE_OVERRIDE_DATABASE_PATH=$CalibreConfig'/metadata.db'

echo CONFIG=$CALIBRE_CONFIG_DIRECTORY
echo LIBRARY=$CALIBRE_LIBRARY_DIRECTORY
echo DATABASE=$CALIBRE_OVERRIDE_DATABASE_PATH

calibre --with-library $LIBRARY_DIR


but it doesn't work. I guess calibre it's not reading the evn variables.
The way I solved is to mount the share using the nobrl option:


mount -t cifs -o nobrl //192.168.1.70/Nicola /media/Nicola


In this way the lock is not propagated to the server.

rootto
09-27-2009, 02:00 PM
I tried the script with a new version of calibre (0.6.13) and the script works, so there is no need to specify the noblr option. I changed the script in order to be able to share the same DB with different computers (no concurrent access, but hey!)


#!/bin/dash

# Batch File to start a Calibre configuration on Windows
# giving explicit control of the location of:
# - Calibe Program Files
# - Calibre Library Files
# - Calibre Config Files
# - Calibre Metadata database
# By setting the paths correctly it can be used to run:
# - A "portable calibre" off a USB stick.
# - A network installation with local metadata database
# (for performance) and books stored on a network share

CalibreConfig=/home/`whoami`/.config/calibre
LIBRARY_DIR='/media/Nicola/Ebooks/'

export CALIBRE_CONFIG_DIRECTORY=$CalibreConfig
export CALIBRE_LIBRARY_DIRECTORY=$LIBRARY_DIR
export CALIBRE_OVERRIDE_DATABASE_PATH=$CalibreConfig'/metadata.db'

echo CONFIG=$CALIBRE_CONFIG_DIRECTORY
echo LIBRARY=$CALIBRE_LIBRARY_DIRECTORY
echo DATABASE=$CALIBRE_OVERRIDE_DATABASE_PATH

cp $LIBRARY_DIR'/metadata.db' $CalibreConfig
calibre --with-library $LIBRARY_DIR
cp $CalibreConfig'/metadata.db' $LIBRARY_DIR'/metadata.db'

itimpi
09-27-2009, 02:03 PM
I had not spotted that you were using such an old version of Calibre. Most of the options in the script have been introduced quite recently - in fact the one to specify the location of the metadata.db file was new in 0.6.13.