Skip to content

Commit 80ae5ab

Browse files
committed
Skip connection check during download if files are already local
This applies to "downloads" that actually just toggle the caching status from "permanently cached" to just "cached" (and back). In these cases the connection check is skipped which would prevent the tasks from being run and trigger a warning. Fixes daneren2005#922
1 parent 449a6dc commit 80ae5ab

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

app/src/main/java/github/daneren2005/dsub/service/DownloadService.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,6 @@ public synchronized void downloadBackground(List<MusicDirectory.Entry> songs, bo
536536
}
537537
revision++;
538538

539-
if(!Util.isOffline(this) && !Util.isNetworkConnected(this)) {
540-
Util.toast(this, R.string.select_album_no_network);
541-
}
542-
543539
checkDownloads();
544540
lifecycleSupport.serializeDownloadQueue();
545541
}
@@ -2269,7 +2265,17 @@ public synchronized void checkDownloads() {
22692265
checkArtistRadio();
22702266
}
22712267

2272-
if (!Util.isAllowedToDownload(this)) {
2268+
// If all files are local (like when permanently caching an already cached file) do not check if device is offline
2269+
boolean skipNetworkCheck = true;
2270+
for (DownloadFile d: downloadList) {
2271+
skipNetworkCheck &= d.isCompleteFileAvailable();
2272+
}
2273+
for (DownloadFile d: backgroundDownloadList) {
2274+
skipNetworkCheck &= d.isCompleteFileAvailable();
2275+
}
2276+
2277+
if (!skipNetworkCheck && !Util.isAllowedToDownload(this)) {
2278+
Util.toast(this, R.string.select_album_no_network);
22732279
return;
22742280
}
22752281

0 commit comments

Comments
 (0)