add field lock and scriptId

if the database connection fails during adding of files, some files
will be left in state added and not be picked up again. This needs
manual intervention to fix.

This patch adds an additional field to the database 'lock' that holds
the scriptId of the packing script. If the packing script finds files
that were locked by itself it will reset these to state 'new' and
thus make manual intervention unnecessary.
fix two syntax errors from previous change
improve log messages
remove container if db exceptions occur during adding of files
Merge pull request #1 from kschwank/addLock

Add lock