forked from trav/lintunes
v0.20.4: the song that wasn't there
trav couldn't play the first track of his playlist. Shuffle off gave him song two; shuffle on gave him a random one. The player was right both times: library.json named a song whose file was not on the device, and skipping an unplayable file advances one slot. Tapping any song that *is* there plays exactly that song, shuffle or not. The file was missing because a gvfs-MTP mount can hold a phantom directory -- one it lists happily while the device has no such folder. Every write into it fails EIO, and mkdir(exist_ok=True) sees the phantom and does nothing, so it never heals; only remounting clears it. That folder was new because Round 52's retag moved the file under a new artist. So a copy that raises OSError now costs that song, not the sync, and the song is left out of the m3u and library.json. Aborting cost 2,400 songs for one folder; counting it present anyway put a song in the manifest that isn't on the device, which is the bug you could hear. The names come back in the summary and a dialog rather than vanishing. Planning is a worker now. plan_andtunes_sync is pure and writes nothing, but it walks every file on the device, and over MTP that is thousands of round trips -- on the GUI thread it froze the window and GNOME offered to kill LinTunes, which is how a sync got force-quit halfway through. And the sync stopped going quiet at the end. "Album art 501/501" is emitted before the last album, and then _write_index, _ship_buttons and _prune_empty_dirs ran silently: 501 exists() stats over MTP, ~840 KB of writes and a full tree walk, with the progress line frozen. They report now, and _write_index reads Art/ in one listing instead of a stat per album. andTunes 0.2.2: the wheel scrolls the other way in lists, and smoothly -- a detent adds to a pixel debt that a Choreographer callback pays off a fraction per frame, so one detent eases to a stop and a fast spin blends into one movement instead of teleporting a row at a time. Volume is unchanged. Claude-Session: https://claude.ai/code/session_01SKXUgsBBwe3qaHEjeV8ubP
This commit is contained in:
+39
-12
@@ -167,6 +167,7 @@ class MainWindow(QMainWindow):
|
||||
self._sync_cancel.clicked.connect(self._confirm_cancel_sync)
|
||||
self.statusBar().addPermanentWidget(self._sync_cancel)
|
||||
self._andtunes_worker = None
|
||||
self._andtunes_planner = None
|
||||
self._install_worker = None
|
||||
self._sync_device_name = ""
|
||||
# Export shares the status-bar progress widgets with device sync —
|
||||
@@ -465,8 +466,8 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def _busy_worker(self):
|
||||
"""The transfer currently owning the status-bar progress widgets."""
|
||||
for worker in (self._andtunes_worker, self._export_worker,
|
||||
self._url_worker):
|
||||
for worker in (self._andtunes_planner, self._andtunes_worker,
|
||||
self._export_worker, self._url_worker):
|
||||
if worker is not None and worker.busy():
|
||||
return worker
|
||||
return None
|
||||
@@ -548,17 +549,26 @@ class MainWindow(QMainWindow):
|
||||
"Pick them in Connections → Rabbit Sync Settings…")
|
||||
return
|
||||
|
||||
# Planning walks the whole device over MTP — off the GUI thread, or
|
||||
# the window freezes and GNOME offers to kill it mid-sync.
|
||||
root = andtunes_layout.root_for(device)
|
||||
try:
|
||||
plan = andtunes_sync.plan_andtunes_sync(
|
||||
playlists, self._manager.library.tracks, root, device,
|
||||
copy_art=bool(self._prefs.device_sync.get("copy_art", True)),
|
||||
data_dir=self._manager.data_dir)
|
||||
free = shutil.disk_usage(device.root).free
|
||||
except OSError as e:
|
||||
QMessageBox.warning(self, "Sync failed",
|
||||
f"Couldn't read the {device.name}: {e}")
|
||||
return
|
||||
self._andtunes_planner = andtunes_sync.AndTunesPlanWorker(
|
||||
playlists, self._manager.library.tracks, root, device,
|
||||
copy_art=bool(self._prefs.device_sync.get("copy_art", True)),
|
||||
data_dir=self._manager.data_dir, parent=self)
|
||||
self._andtunes_planner.planned.connect(self._on_andtunes_planned)
|
||||
self._andtunes_planner.failed.connect(self._on_sync_failed)
|
||||
self._sync_device_name = device.name
|
||||
self._sync_label.setText(f"Checking the {device.name}")
|
||||
self._sync_progress.setRange(0, 0) # busy bar: no total to show yet
|
||||
self._sync_label.show()
|
||||
self._sync_progress.show()
|
||||
self._andtunes_planner.start()
|
||||
|
||||
def _on_andtunes_planned(self, plan, free):
|
||||
device = plan.device
|
||||
playlists = plan.playlists
|
||||
self._hide_sync_widgets()
|
||||
if plan.needs_ffmpeg and not exporter.web_support.ffmpeg_available():
|
||||
conversions = plan.conversions
|
||||
names = "\n".join(f" • {device_sync.track_display(i.track)}"
|
||||
@@ -618,12 +628,29 @@ class MainWindow(QMainWindow):
|
||||
msg += f", {summary['refused']} left out (can't play there)"
|
||||
if summary.get("unconverted"):
|
||||
msg += f", {summary['unconverted']} couldn't be converted"
|
||||
unwritable = summary.get("unwritable") or []
|
||||
if unwritable:
|
||||
msg += f", {len(unwritable)} the device wouldn't take"
|
||||
if summary.get("plays"):
|
||||
msg += f"; play counts back for {summary['plays']} song(s)"
|
||||
# The journal landed in the data dir; fold it in now rather than
|
||||
# waiting for the file watcher.
|
||||
self._manager.reload_from_disk()
|
||||
self.statusBar().showMessage(msg, 10000)
|
||||
if unwritable:
|
||||
# Worth a dialog: these songs are *not* in the library the app
|
||||
# reads, so they'd otherwise just be quietly absent from the
|
||||
# playlist. A stale gvfs mount is the usual cause.
|
||||
names = "\n".join(f" • {name} — {why}" for name, why in unwritable[:8])
|
||||
more = (f"\n … and {len(unwritable) - 8} more"
|
||||
if len(unwritable) > 8 else "")
|
||||
QMessageBox.warning(
|
||||
self, "Some songs wouldn't copy",
|
||||
f"The {summary['device']} refused "
|
||||
f"{len(unwritable)} song(s):\n\n{names}{more}\n\n"
|
||||
"They've been left out of the library on the device, so the "
|
||||
"app won't list a song it can't play. Unplugging the "
|
||||
"device and plugging it back in usually clears this.")
|
||||
|
||||
# ---- connections: install the andTunes app ----
|
||||
|
||||
|
||||
Reference in New Issue
Block a user