avoid locking the database greedily during import

Previously, the db transaction was running concurrently with the file copying
and tag writing. This meant that the transaction went needlessly long and made
other db-writing processes time out. Now the transaction is short and occurs
after all the file operations.
This commit is contained in:
Adrian Sampson 2010-06-08 23:34:44 -07:00
parent 568c44275f
commit e5f7ee67ca

View file

@ -284,16 +284,20 @@ def tag_album(items, lib, copy=True, write=True):
(artist, album)
return
# Change metadata and add to library.
# Change metadata, move, and copy.
if info is not CHOICE_ASIS:
autotag.apply_metadata(items, info)
for item in items:
if copy:
item.move(lib, True)
lib.add(item)
if write and info is not CHOICE_ASIS:
item.write()
# Add items to library. We consolidate this at the end to avoid
# locking while we do the copying and tag updates.
for item in items:
lib.add(item)
# Top-level commands.