From e5f7ee67ca3bd0ec2a3ba3f1e0f0d5c1ad786291 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 8 Jun 2010 23:34:44 -0700 Subject: [PATCH] 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. --- beets/ui.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/beets/ui.py b/beets/ui.py index 2f7540e1e..394b8022b 100644 --- a/beets/ui.py +++ b/beets/ui.py @@ -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.