mirror of
https://github.com/beetbox/beets.git
synced 2026-01-03 14:32:55 +01:00
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:
parent
568c44275f
commit
e5f7ee67ca
1 changed files with 6 additions and 2 deletions
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue