Don't rewrite the paths of songs on afc devices, and mark them as streams in the playlist so they won't get re-read on startup
This commit is contained in:
parent
68d7156071
commit
d29fb119a4
@ -34,7 +34,7 @@ AfcDevice::AfcDevice(
|
||||
// Make a new temporary directory for the iTunesDB. We copy it off the iPod
|
||||
// so that libgpod can have a local directory to use.
|
||||
local_path_ = Utilities::MakeTempDir();
|
||||
InitBackendDirectory(local_path_, first_time);
|
||||
InitBackendDirectory(local_path_, first_time, false);
|
||||
model_->Init();
|
||||
|
||||
transfer_ = new AfcTransfer(url.host(), local_path_, manager_->task_manager());
|
||||
@ -57,6 +57,7 @@ void AfcDevice::CopyFinished() {
|
||||
// Now load the songs from the local database
|
||||
loader_ = new GPodLoader(local_path_, manager_->task_manager(), backend_);
|
||||
loader_->set_music_path_prefix("afc://" + url_.host());
|
||||
loader_->set_song_type(Song::Type_Stream);
|
||||
loader_->moveToThread(loader_thread_);
|
||||
|
||||
connect(loader_, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
|
@ -54,22 +54,25 @@ ConnectedDevice::~ConnectedDevice() {
|
||||
backend_->deleteLater();
|
||||
}
|
||||
|
||||
void ConnectedDevice::InitBackendDirectory(const QString& mount_point, bool first_time) {
|
||||
void ConnectedDevice::InitBackendDirectory(
|
||||
const QString& mount_point, bool first_time, bool rewrite_path) {
|
||||
if (first_time)
|
||||
backend_->AddDirectory(mount_point);
|
||||
else {
|
||||
// This is a bit of a hack. The device might not be mounted at the same
|
||||
// path each time, so if it's different we have to munge all the paths in
|
||||
// the database to fix it. This can be done entirely in sqlite so it's
|
||||
// relatively fast...
|
||||
if (rewrite_path) {
|
||||
// This is a bit of a hack. The device might not be mounted at the same
|
||||
// path each time, so if it's different we have to munge all the paths in
|
||||
// the database to fix it. This can be done entirely in sqlite so it's
|
||||
// relatively fast...
|
||||
|
||||
// Get the directory it was mounted at last time. Devices only have one
|
||||
// directory (the root).
|
||||
Directory dir = backend_->GetAllDirectories()[0];
|
||||
if (dir.path != mount_point) {
|
||||
// The directory is different, commence the munging.
|
||||
qDebug() << "Changing path from" << dir.path << "to" << mount_point;
|
||||
backend_->ChangeDirPath(dir.id, mount_point);
|
||||
// Get the directory it was mounted at last time. Devices only have one
|
||||
// directory (the root).
|
||||
Directory dir = backend_->GetAllDirectories()[0];
|
||||
if (dir.path != mount_point) {
|
||||
// The directory is different, commence the munging.
|
||||
qDebug() << "Changing path from" << dir.path << "to" << mount_point;
|
||||
backend_->ChangeDirPath(dir.id, mount_point);
|
||||
}
|
||||
}
|
||||
|
||||
// Load the directory properly now
|
||||
|
@ -50,7 +50,7 @@ signals:
|
||||
void Error(const QString& message);
|
||||
|
||||
protected:
|
||||
void InitBackendDirectory(const QString& mount_point, bool first_time);
|
||||
void InitBackendDirectory(const QString& mount_point, bool first_time, bool rewrite_path = true);
|
||||
|
||||
protected:
|
||||
QUrl url_;
|
||||
|
@ -27,6 +27,7 @@ GPodLoader::GPodLoader(const QString& mount_point, TaskManager* task_manager,
|
||||
LibraryBackend* backend, QObject *parent)
|
||||
: QObject(parent),
|
||||
mount_point_(mount_point),
|
||||
type_(Song::Type_Unknown),
|
||||
task_manager_(task_manager),
|
||||
backend_(backend)
|
||||
{
|
||||
@ -60,6 +61,8 @@ void GPodLoader::LoadDatabase() {
|
||||
song.set_directory_id(1);
|
||||
song.set_filename((path_prefix_.isEmpty() ? mount_point_ : path_prefix_) +
|
||||
song.filename());
|
||||
if (type_ != Song::Type_Unknown)
|
||||
song.set_filetype(type_);
|
||||
songs << song;
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,10 @@
|
||||
#include <QObject>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <gpod/itdb.h>
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
class LibraryBackend;
|
||||
class TaskManager;
|
||||
|
||||
@ -34,6 +35,7 @@ public:
|
||||
LibraryBackend* backend, QObject* parent = 0);
|
||||
|
||||
void set_music_path_prefix(const QString& prefix) { path_prefix_ = prefix; }
|
||||
void set_song_type(Song::FileType type) { type_ = type; }
|
||||
|
||||
public slots:
|
||||
void LoadDatabase();
|
||||
@ -48,6 +50,7 @@ private:
|
||||
|
||||
QString mount_point_;
|
||||
QString path_prefix_;
|
||||
Song::FileType type_;
|
||||
TaskManager* task_manager_;
|
||||
LibraryBackend* backend_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user