• R/O
  • SSH

Commit

Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

Commit MetaInfo

Revisãocd03cc05fb9118749950d6374aae11ccc12fea61 (tree)
Hora2017-12-26 20:53:57
AutorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fast...>
CommiterJaime Marquínez Ferrándiz

Mensagem de Log

Reduce the number of transactions

Mudança Sumário

Diff

diff -r 0704aeb551aa -r cd03cc05fb91 beetsplug/playersync.py
--- a/beetsplug/playersync.py Tue Dec 26 12:49:35 2017 +0100
+++ b/beetsplug/playersync.py Tue Dec 26 12:53:57 2017 +0100
@@ -63,27 +63,27 @@
6363 db.execute('DELETE FROM playlistsong')
6464
6565 for query in config['queries'].get(list):
66- self.info('Processing query: "{0}"', query)
67- items = lib.items(query)
68- for item in items:
69- self.add_item(lib, db, item)
7066 with db:
67+ self.info('Processing query: "{0}"', query)
68+ items = lib.items(query)
69+ for item in items:
70+ self.add_item(lib, db, item)
7171 db.execute('INSERT INTO query (query) VALUES (?)', (query,))
7272 query_id = db.execute('SELECT idQuery FROM query WHERE query=?', (query,)).fetchone()[0]
7373 db.executemany('INSERT INTO querysong VALUES (?, ?)', [(query_id, item['id']) for item in items])
7474
7575 for playlist in config['playlists'].get(list):
76- self.info('Processing playlist: "{0}"', playlist)
77- playlist_file = os.path.expanduser(playlist)
78- with open(playlist_file, 'rt') as f:
79- paths = [line for line in (line.strip() for line in f) if line and not line.startswith('#')]
80- items = []
81- for song_path in paths:
82- query, q_sort = parse_query_parts(['path:' + song_path], Item)
83- item = list(lib.items(OrQuery(query)))[0]
84- self.add_item(lib, db, item)
85- items.append(item)
8676 with db:
77+ self.info('Processing playlist: "{0}"', playlist)
78+ playlist_file = os.path.expanduser(playlist)
79+ with open(playlist_file, 'rt') as f:
80+ paths = [line for line in (line.strip() for line in f) if line and not line.startswith('#')]
81+ items = []
82+ for song_path in paths:
83+ query, q_sort = parse_query_parts(['path:' + song_path], Item)
84+ item = list(lib.items(OrQuery(query)))[0]
85+ self.add_item(lib, db, item)
86+ items.append(item)
8787 db.execute(
8888 'INSERT INTO playlist (playlist) VALUES (?)',
8989 (playlist,))
@@ -146,5 +146,4 @@
146146 if IS_PY3 and isinstance(copy_path, bytes):
147147 copy_path = copy_path.decode()
148148 if not db.execute('SELECT * FROM song WHERE idSong=?', (item_id,)).fetchall():
149- with db:
150- db.execute('INSERT INTO song (idSong, filename) VALUES (?,?)', (item_id, copy_path))
149+ db.execute('INSERT INTO song (idSong, filename) VALUES (?,?)', (item_id, copy_path))