Skip to content

Commit

Permalink
Merge pull request beetbox#4258 from beetbox/rectify-4226
Browse files Browse the repository at this point in the history
convert: Revert some recent changes to convert-on-import path
  • Loading branch information
wisp3rwind authored Jan 30, 2022
2 parents 19e4f41 + 2b51b24 commit 10338c2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 29 deletions.
33 changes: 16 additions & 17 deletions beetsplug/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import tempfile
import shlex
from string import Template
import logging

from beets import ui, util, plugins, config
from beets.plugins import BeetsPlugin
Expand Down Expand Up @@ -514,23 +515,21 @@ def convert_on_import(self, lib, item):
except subprocess.CalledProcessError:
return

pretend = self.config['pretend'].get(bool)
quiet = self.config['quiet'].get(bool)

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)
# 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']:
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:
Expand Down
2 changes: 0 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,6 @@ def test_delete_originals(self):
'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

Expand Down

0 comments on commit 10338c2

Please sign in to comment.