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
|
// Make a new temporary directory for the iTunesDB. We copy it off the iPod
|
||||||
// so that libgpod can have a local directory to use.
|
// so that libgpod can have a local directory to use.
|
||||||
local_path_ = Utilities::MakeTempDir();
|
local_path_ = Utilities::MakeTempDir();
|
||||||
InitBackendDirectory(local_path_, first_time);
|
InitBackendDirectory(local_path_, first_time, false);
|
||||||
model_->Init();
|
model_->Init();
|
||||||
|
|
||||||
transfer_ = new AfcTransfer(url.host(), local_path_, manager_->task_manager());
|
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
|
// Now load the songs from the local database
|
||||||
loader_ = new GPodLoader(local_path_, manager_->task_manager(), backend_);
|
loader_ = new GPodLoader(local_path_, manager_->task_manager(), backend_);
|
||||||
loader_->set_music_path_prefix("afc://" + url_.host());
|
loader_->set_music_path_prefix("afc://" + url_.host());
|
||||||
|
loader_->set_song_type(Song::Type_Stream);
|
||||||
loader_->moveToThread(loader_thread_);
|
loader_->moveToThread(loader_thread_);
|
||||||
|
|
||||||
connect(loader_, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
connect(loader_, SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||||
|
@ -54,10 +54,12 @@ ConnectedDevice::~ConnectedDevice() {
|
|||||||
backend_->deleteLater();
|
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)
|
if (first_time)
|
||||||
backend_->AddDirectory(mount_point);
|
backend_->AddDirectory(mount_point);
|
||||||
else {
|
else {
|
||||||
|
if (rewrite_path) {
|
||||||
// This is a bit of a hack. The device might not be mounted at the same
|
// 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
|
// 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
|
// the database to fix it. This can be done entirely in sqlite so it's
|
||||||
@ -71,6 +73,7 @@ void ConnectedDevice::InitBackendDirectory(const QString& mount_point, bool firs
|
|||||||
qDebug() << "Changing path from" << dir.path << "to" << mount_point;
|
qDebug() << "Changing path from" << dir.path << "to" << mount_point;
|
||||||
backend_->ChangeDirPath(dir.id, mount_point);
|
backend_->ChangeDirPath(dir.id, mount_point);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load the directory properly now
|
// Load the directory properly now
|
||||||
backend_->LoadDirectoriesAsync();
|
backend_->LoadDirectoriesAsync();
|
||||||
|
@ -50,7 +50,7 @@ signals:
|
|||||||
void Error(const QString& message);
|
void Error(const QString& message);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void InitBackendDirectory(const QString& mount_point, bool first_time);
|
void InitBackendDirectory(const QString& mount_point, bool first_time, bool rewrite_path = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QUrl url_;
|
QUrl url_;
|
||||||
|
@ -27,6 +27,7 @@ GPodLoader::GPodLoader(const QString& mount_point, TaskManager* task_manager,
|
|||||||
LibraryBackend* backend, QObject *parent)
|
LibraryBackend* backend, QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
mount_point_(mount_point),
|
mount_point_(mount_point),
|
||||||
|
type_(Song::Type_Unknown),
|
||||||
task_manager_(task_manager),
|
task_manager_(task_manager),
|
||||||
backend_(backend)
|
backend_(backend)
|
||||||
{
|
{
|
||||||
@ -60,6 +61,8 @@ void GPodLoader::LoadDatabase() {
|
|||||||
song.set_directory_id(1);
|
song.set_directory_id(1);
|
||||||
song.set_filename((path_prefix_.isEmpty() ? mount_point_ : path_prefix_) +
|
song.set_filename((path_prefix_.isEmpty() ? mount_point_ : path_prefix_) +
|
||||||
song.filename());
|
song.filename());
|
||||||
|
if (type_ != Song::Type_Unknown)
|
||||||
|
song.set_filetype(type_);
|
||||||
songs << song;
|
songs << song;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,10 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include <gpod/itdb.h>
|
#include <gpod/itdb.h>
|
||||||
|
|
||||||
|
#include "core/song.h"
|
||||||
|
|
||||||
class LibraryBackend;
|
class LibraryBackend;
|
||||||
class TaskManager;
|
class TaskManager;
|
||||||
|
|
||||||
@ -34,6 +35,7 @@ public:
|
|||||||
LibraryBackend* backend, QObject* parent = 0);
|
LibraryBackend* backend, QObject* parent = 0);
|
||||||
|
|
||||||
void set_music_path_prefix(const QString& prefix) { path_prefix_ = prefix; }
|
void set_music_path_prefix(const QString& prefix) { path_prefix_ = prefix; }
|
||||||
|
void set_song_type(Song::FileType type) { type_ = type; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void LoadDatabase();
|
void LoadDatabase();
|
||||||
@ -48,6 +50,7 @@ private:
|
|||||||
|
|
||||||
QString mount_point_;
|
QString mount_point_;
|
||||||
QString path_prefix_;
|
QString path_prefix_;
|
||||||
|
Song::FileType type_;
|
||||||
TaskManager* task_manager_;
|
TaskManager* task_manager_;
|
||||||
LibraryBackend* backend_;
|
LibraryBackend* backend_;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user