Merge pull request #4258 from beetbox/rectify-4226

convert: Revert some recent changes to convert-on-import path
This commit is contained in:
Benedikt 2022-01-30 11:30:48 +01:00 committed by GitHub
commit 10338c2a60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 28 deletions

View file

@ -22,6 +22,7 @@ import subprocess
import tempfile
import shlex
from string import Template
import logging
from beets import ui, util, plugins, config
from beets.plugins import BeetsPlugin
@ -514,23 +515,21 @@ class ConvertPlugin(BeetsPlugin):
except subprocess.CalledProcessError:
return
pretend = self.config['pretend'].get(bool)
quiet = self.config['quiet'].get(bool)
# Change the newly-imported database entry to point to the
# converted file.
source_path = item.path
item.path = dest
item.write()
item.read() # Load new audio information data.
item.store()
if not pretend:
# Change the newly-imported database entry to point to the
# converted file.
source_path = item.path
item.path = dest
item.write()
item.read() # Load new audio information data.
item.store()
if self.config['delete_originals']:
if not quiet:
self._log.info('Removing original file {0}',
source_path)
util.remove(source_path, False)
if self.config['delete_originals']:
self._log.log(
logging.DEBUG if self.config['quiet'] else logging.INFO,
'Removing original file {0}',
source_path,
)
util.remove(source_path, False)
def _cleanup(self, task, session):
for path in task.old_paths:

View file

@ -32,8 +32,6 @@ Bug fixes:
* Fix a regression in the previous release that caused a `TypeError` when
moving files across filesystems.
:bug:`4168`
* :doc:`/plugins/convert`: Files are no longer converted when running import in
``--pretend`` mode.
* :doc:`/plugins/convert`: Deleting the original files during conversion no
longer logs output when the ``quiet`` flag is enabled.
* :doc:`plugins/web`: Fix handling of "query" requests. Previously queries

View file

@ -127,16 +127,6 @@ class ImportConvertTest(unittest.TestCase, TestHelper):
'Non-empty import directory {}'
.format(util.displayable_path(path)))
def test_delete_originals_keeps_originals_when_pretend_enabled(self):
import_file_count = self.get_count_of_import_files()
self.config['convert']['delete_originals'] = True
self.config['convert']['pretend'] = True
self.importer.run()
self.assertEqual(self.get_count_of_import_files(), import_file_count,
'Count of files differs after running import')
def get_count_of_import_files(self):
import_file_count = 0