mirror of
https://github.com/beetbox/beets.git
synced 2025-12-24 01:25:47 +01:00
convert: atomic mkdirall() call
This commit is contained in:
parent
b81ac1d6e0
commit
cc8ead7e34
1 changed files with 8 additions and 3 deletions
|
|
@ -16,8 +16,8 @@
|
|||
"""
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import threading
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
|
@ -27,7 +27,7 @@ from beetsplug.embedart import _embed
|
|||
log = logging.getLogger('beets')
|
||||
DEVNULL = open(os.devnull, 'wb')
|
||||
conf = {}
|
||||
|
||||
_fs_lock = threading.Lock()
|
||||
|
||||
|
||||
def encode(source, dest):
|
||||
|
|
@ -77,7 +77,12 @@ def convert_item(lib, dest_dir):
|
|||
))
|
||||
continue
|
||||
|
||||
util.mkdirall(dest)
|
||||
# Ensure that only one thread tries to create directories at a
|
||||
# time. (The existence check is not atomic with the directory
|
||||
# creation inside this function.)
|
||||
with _fs_lock:
|
||||
util.mkdirall(dest)
|
||||
|
||||
if item.format == 'MP3' and item.bitrate < 1000 * conf['max_bitrate']:
|
||||
log.info('Copying {0}'.format(util.displayable_path(item.path)))
|
||||
util.copy(item.path, dest)
|
||||
|
|
|
|||
Loading…
Reference in a new issue