From 01ab305fabf7936d44b0f6af8de6ecb4c670cb20 Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Wed, 18 Jun 2014 09:21:59 -0700 Subject: Fix stalling downloads when just switching complete to pin --- src/github/daneren2005/dsub/service/DownloadFile.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java index 5a9af6d6..c82607f5 100644 --- a/src/github/daneren2005/dsub/service/DownloadFile.java +++ b/src/github/daneren2005/dsub/service/DownloadFile.java @@ -357,7 +357,6 @@ public class DownloadFile implements BufferFile { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, toString()); wakeLock.acquire(); - Log.i(TAG, "Acquired wake lock " + wakeLock); } wifiLock = Util.createWifiLock(context, toString()); @@ -365,6 +364,7 @@ public class DownloadFile implements BufferFile { if (saveFile.exists()) { Log.i(TAG, saveFile + " already exists. Skipping."); + checkDownloads(); return null; } if (completeFile.exists()) { @@ -377,6 +377,7 @@ public class DownloadFile implements BufferFile { } else { Log.i(TAG, completeFile + " already exists. Skipping."); } + checkDownloads(); return null; } @@ -477,13 +478,17 @@ public class DownloadFile implements BufferFile { // Only run these if not interrupted, ie: cancelled new CacheCleaner(context, DownloadService.getInstance()).cleanSpace(); - - if(DownloadService.getInstance() != null) { - DownloadService.getInstance().checkDownloads(); - } + checkDownloads(); return null; } + + private void checkDownloads() { + DownloadService downloadService = DownloadService.getInstance(); + if(downloadService != null) { + downloadService.checkDownloads(); + } + } @Override public String toString() { -- cgit v1.2.3