From f371960746141f11acf147e556ba55f58cd992f6 Mon Sep 17 00:00:00 2001 From: billypom on debian Date: Sun, 16 Mar 2025 12:17:13 -0400 Subject: [PATCH] bugfix when reorganizing to same reorganize directory --- README.md | 25 +++++++++++++------------ components/MusicTable.py | 18 +++++++++++------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 59887ba..6b2a54f 100644 --- a/README.md +++ b/README.md @@ -34,15 +34,16 @@ python3 main.py ## Todo: -- [x] right-click menu -- [x] editable lyrics window -- [x] batch metadata changer (red highlight fields that have differing info) -- [x] playlists -- [ ] delete songs from library (del key || right-click delete) -- [ ] .wav, .ogg, .flac convertor -- [ ] FIXME: dbaccess is instantiated for every track being reorganized -- [ ] automatic "radio" based on artist or genre -- [ ] search bar, full text search on song, artist, album -- [ ] when table is focused, start typing to match against the primary sort column -- [ ] "installer" - put files in /opt? script to install and uninstall -- [ ] .deb package? +- ~~right-click menu~~ +- ~~editable lyrics window~~ +- ~~batch metadata changer (red highlight fields that have differing info)~~ +- ~~playlists~~ +- playlist autoexporting +- delete songs from library (del key || right-click delete) +- .wav, .ogg, .flac convertor +- FIXME: dbaccess is instantiated for every track being reorganized +- automatic "radio" based on artist or genre +- search bar, full text search on song, artist, album +- when table is focused, start typing to match against the primary sort column +- "installer" - put files in /opt? script to install and uninstall +- .deb package? diff --git a/components/MusicTable.py b/components/MusicTable.py index 3081648..729801e 100644 --- a/components/MusicTable.py +++ b/components/MusicTable.py @@ -494,23 +494,27 @@ class MusicTable(QTableView): Reorganizes files into Artist/Album/Song, based on self.config['directories'][reorganize_destination'] """ + debug('reorganizing files') # Get target directory target_dir = str(self.config["directories"]["reorganize_destination"]) for filepath in filepaths: - if str(filepath).startswith((target_dir)): + # Read file metadata + artist, album = get_reorganize_vars(filepath) + # Determine the new path that needs to be made + new_path = os.path.join( + target_dir, artist, album, os.path.basename(filepath) + ) + # Need to determine if filepath is equal + if new_path == filepath: continue try: if progress_callback: progress_callback.emit(f"Organizing: {filepath}") - # Read file metadata - artist, album = get_reorganize_vars(filepath) - # Determine the new path that needs to be made - new_path = os.path.join( - target_dir, artist, album, os.path.basename(filepath) - ) # Create the directories if they dont exist + debug('make dirs') os.makedirs(os.path.dirname(new_path), exist_ok=True) # Move the file to the new directory + debug(f'{filepath} > {new_path}') shutil.move(filepath, new_path) # Update the db with DBA.DBAccess() as db: