Compare commits
2 Commits
ecd5c65695
...
57765a64a7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57765a64a7 | ||
|
|
c7253e2211 |
@ -204,12 +204,14 @@ class ReplaceFilesDialog(QDialog):
|
|||||||
if candidates_by_title:
|
if candidates_by_title:
|
||||||
# Check artist tag
|
# Check artist tag
|
||||||
for cbt in candidates_by_title:
|
for cbt in candidates_by_title:
|
||||||
|
if not os.path.exists(cbt.path):
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
cbt_artist = get_tags(cbt.path)["artist"]
|
cbt_artist = get_tags(cbt.path)["artist"]
|
||||||
if cbt_artist.lower() == new_path_artist.lower():
|
if cbt_artist.lower() == new_path_artist.lower():
|
||||||
match_track = cbt
|
match_track = cbt
|
||||||
break
|
break
|
||||||
except FileNotFoundError:
|
except KeyError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return match_track
|
return match_track
|
||||||
|
|||||||
@ -1338,10 +1338,14 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
session.commit()
|
session.commit()
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
# https://jira.mariadb.org/browse/MDEV-29345 workaround
|
# https://jira.mariadb.org/browse/MDEV-29345 workaround
|
||||||
|
log.debug(
|
||||||
|
"Working around https://jira.mariadb.org/browse/MDEV-29345"
|
||||||
|
)
|
||||||
session.rollback()
|
session.rollback()
|
||||||
track.path = "DUMMY"
|
track.path = "DUMMY"
|
||||||
session.commit()
|
session.commit()
|
||||||
track.path = rf.track_path
|
track.path = rf.track_path
|
||||||
|
session.commit()
|
||||||
else:
|
else:
|
||||||
session.commit()
|
session.commit()
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -92,7 +92,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
# Ensure row numbers in playlist are contiguous
|
# Ensure row numbers in playlist are contiguous
|
||||||
PlaylistRows.fixup_rownumbers(session, playlist_id)
|
PlaylistRows.fixup_rownumbers(session, playlist_id)
|
||||||
# Populate self.playlist_rows
|
# Populate self.playlist_rows
|
||||||
self.refresh_data(session)
|
self.load_data(session)
|
||||||
self.update_track_times()
|
self.update_track_times()
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
@ -803,8 +803,10 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.update_track_times()
|
self.update_track_times()
|
||||||
self.invalidate_rows(list(row_map.keys()))
|
self.invalidate_rows(list(row_map.keys()))
|
||||||
|
|
||||||
|
@line_profiler.profile
|
||||||
def move_rows_between_playlists(
|
def move_rows_between_playlists(
|
||||||
self, from_rows: list[int], to_row_number: int, to_playlist_id: int
|
self, from_rows: list[int], to_row_number: int, to_playlist_id: int,
|
||||||
|
dummy_for_profiling=None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Move the playlist rows given to to_row and below of to_playlist.
|
Move the playlist rows given to to_row and below of to_playlist.
|
||||||
@ -1002,6 +1004,33 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
# Copy to self.playlist_rows
|
# Copy to self.playlist_rows
|
||||||
self.playlist_rows = new_playlist_rows
|
self.playlist_rows = new_playlist_rows
|
||||||
|
|
||||||
|
# Same as refresh data, but only used when creating playslit.
|
||||||
|
# Distinguishes profile time between initial load and other
|
||||||
|
# refreshes.
|
||||||
|
def load_data(self, session: db.session, dummy_for_profiling=None) -> None:
|
||||||
|
"""Populate self.playlist_rows with playlist data"""
|
||||||
|
|
||||||
|
# We used to clear self.playlist_rows each time but that's
|
||||||
|
# expensive and slow on big playlists
|
||||||
|
|
||||||
|
# Note where each playlist_id is
|
||||||
|
plid_to_row: dict[int, int] = {}
|
||||||
|
for oldrow in self.playlist_rows:
|
||||||
|
plrdata = self.playlist_rows[oldrow]
|
||||||
|
plid_to_row[plrdata.playlistrow_id] = plrdata.row_number
|
||||||
|
|
||||||
|
# build a new playlist_rows
|
||||||
|
new_playlist_rows: dict[int, RowAndTrack] = {}
|
||||||
|
for p in PlaylistRows.get_playlist_rows(session, self.playlist_id):
|
||||||
|
if p.id not in plid_to_row:
|
||||||
|
new_playlist_rows[p.row_number] = RowAndTrack(p)
|
||||||
|
else:
|
||||||
|
new_playlist_rows[p.row_number] = self.playlist_rows[plid_to_row[p.id]]
|
||||||
|
new_playlist_rows[p.row_number].row_number = p.row_number
|
||||||
|
|
||||||
|
# Copy to self.playlist_rows
|
||||||
|
self.playlist_rows = new_playlist_rows
|
||||||
|
|
||||||
def refresh_row(self, session, row_number):
|
def refresh_row(self, session, row_number):
|
||||||
"""Populate dict for one row from database"""
|
"""Populate dict for one row from database"""
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user