Commit ba87f8c8 authored by Nicholas Little's avatar Nicholas Little Committed by Andrés G. Aragoneses

Dap: not purge at disconnect & virtualize load (bgo#732634)

For DAP sources where metadata is difficult or costly to extract
(i.e. Bluetooth, as it's a much slower medium), it is useful to
keep the old metadata around to allow for speedy track enumeration
in the cases where files are still present.

To allow for those cases this patch:

- Adds two new virtual methods, PreLoad() and PostLoad(), which
allow subclasses to customise behaviour at those times
(Bluetooth extension will override PreLoad() avoiding the purge
of tracks; and will probably add caching strategies to both
methods).
- Removes calls to PurgeTracks() and PurgeTemporaryPlaylists()
from the Dispose() method, which is called when the device is
disconnected/ejected.

For sources that don't take advantage of this new functionality,
this shouldn't actually result in a change of behaviour (it is
true that the track records will not be deleted from the DB when
the device is disconnected; but this deletion will occur when
the device is connected again anyway, at PreLoad() via
PurgeTracks() and at Initialize() via PurgeTemporaryPlaylists(),
like it used to happen.)
Signed-off-by: default avatarAndrés G. Aragoneses <knocte@gmail.com>
parent ce267cc0
......@@ -112,9 +112,6 @@ namespace Banshee.Dap
Flush ();
PurgeTemporaryPlaylists ();
PurgeTracks ();
if (dap_info_bar != null) {
var info_bar = dap_info_bar;
ThreadAssist.ProxyToMain (info_bar.Destroy);
......@@ -303,21 +300,31 @@ namespace Banshee.Dap
private void ThreadedLoadDeviceContents ()
{
try {
PurgeTracks ();
PreLoad ();
SetStatus (String.Format (Catalog.GetString ("Loading {0}"), Name), false);
LoadFromDevice ();
HideStatus ();
sync.DapLoaded ();
sync.CalculateSync ();
if (sync.AutoSync) {
sync.Sync ();
}
PostLoad ();
} catch (Exception e) {
Log.Error (e);
}
}
protected virtual void PreLoad ()
{
PurgeTracks ();
}
protected virtual void PostLoad ()
{
HideStatus ();
sync.DapLoaded ();
sync.CalculateSync ();
if (sync.AutoSync) {
sync.Sync ();
}
}
public void RemovePlaylists ()
{
// First remove any playlists on the device
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment