From d050fa0d8475cdea8df151c954fc99daad3b7165 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Mon, 6 May 2024 12:12:56 +0100 Subject: [PATCH] Fix file importing Imported track wasn't moved to destination --- app/musicmuster.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/musicmuster.py b/app/musicmuster.py index 090c989..c08b00a 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -184,15 +184,16 @@ class ImportTrack(QObject): f"Importing {basename(tf.source_file_path)}", 5000 ) + # Sanity check + if not os.path.exists(tf.source_file_path): + log.error(f"ImportTrack: file not found: {tf.source_file_path=}") + continue + # Move the track file. Check that we're not importing a # file that's already in its final destination. - if ( - os.path.exists(tf.track_path) - and os.path.exists(tf.source_file_path) - and tf.track_path != tf.source_file_path - ): + if os.path.exists(tf.track_path) and tf.track_path != tf.source_file_path: os.unlink(tf.track_path) - shutil.move(tf.source_file_path, tf.track_path) + shutil.move(tf.source_file_path, tf.track_path) # Import track try: