mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-03 20:57:35 +01:00
Support deletion and reset from Dropbox's delta API.
This commit is contained in:
parent
4ba965115c
commit
3972f939f7
@ -112,7 +112,8 @@ void DropboxService::RequestFileListFinished(QNetworkReply* reply) {
|
|||||||
QVariantMap response = parser.parse(reply).toMap();
|
QVariantMap response = parser.parse(reply).toMap();
|
||||||
if (response.contains("reset") &&
|
if (response.contains("reset") &&
|
||||||
response["reset"].toBool()) {
|
response["reset"].toBool()) {
|
||||||
// TODO: Clear dropbox DB.
|
qLog(Debug) << "Resetting Dropbox DB";
|
||||||
|
library_backend_->DeleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
@ -124,13 +125,25 @@ void DropboxService::RequestFileListFinished(QNetworkReply* reply) {
|
|||||||
foreach (const QVariant& c, contents) {
|
foreach (const QVariant& c, contents) {
|
||||||
QVariantList item = c.toList();
|
QVariantList item = c.toList();
|
||||||
QString path = item[0].toString();
|
QString path = item[0].toString();
|
||||||
|
|
||||||
|
QUrl url;
|
||||||
|
url.setScheme("dropbox");
|
||||||
|
url.setPath(path);
|
||||||
|
|
||||||
|
if (item[1].isNull()) {
|
||||||
|
// Null metadata indicates path deleted.
|
||||||
|
qLog(Debug) << "Deleting:" << url;
|
||||||
|
Song song = library_backend_->GetSongByUrl(url);
|
||||||
|
if (song.is_valid()) {
|
||||||
|
library_backend_->DeleteSongs(SongList() << song);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap metadata = item[1].toMap();
|
QVariantMap metadata = item[1].toMap();
|
||||||
if (metadata["is_dir"].toBool()) {
|
if (metadata["is_dir"].toBool()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QUrl url;
|
|
||||||
url.setScheme("dropbox");
|
|
||||||
url.setPath(path);
|
|
||||||
MaybeAddFileToDatabase(url, metadata);
|
MaybeAddFileToDatabase(url, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user