diff --git a/src/devices/afcdevice.cpp b/src/devices/afcdevice.cpp index 545d618de..6fc1242b3 100644 --- a/src/devices/afcdevice.cpp +++ b/src/devices/afcdevice.cpp @@ -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))); diff --git a/src/devices/connecteddevice.cpp b/src/devices/connecteddevice.cpp index 174f32c97..4d456aaf1 100644 --- a/src/devices/connecteddevice.cpp +++ b/src/devices/connecteddevice.cpp @@ -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 diff --git a/src/devices/connecteddevice.h b/src/devices/connecteddevice.h index fe34a2f54..c1f69071b 100644 --- a/src/devices/connecteddevice.h +++ b/src/devices/connecteddevice.h @@ -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_; diff --git a/src/devices/gpodloader.cpp b/src/devices/gpodloader.cpp index eba6e9803..38dafaae9 100644 --- a/src/devices/gpodloader.cpp +++ b/src/devices/gpodloader.cpp @@ -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; } diff --git a/src/devices/gpodloader.h b/src/devices/gpodloader.h index 93ee7c54a..078d9ac4a 100644 --- a/src/devices/gpodloader.h +++ b/src/devices/gpodloader.h @@ -20,9 +20,10 @@ #include #include - #include +#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_; };