Merge pull request #2665 from ByteHamster/prevent-thrashing

Prevent thrashing the database by opening and closing rapidly
This commit is contained in:
Martin Fietz 2018-09-30 13:33:02 +02:00 committed by GitHub
commit c105a63165
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import android.util.Log;
import android.util.Pair;
import android.webkit.URLUtil;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
import org.apache.commons.io.FileUtils;
import org.xml.sax.SAXException;
@ -256,6 +257,7 @@ public class DownloadService extends Service {
public void onCreate() {
Log.d(TAG, "Service started");
isRunning = true;
PodDBAdapter.getInstance().open(); // Prevent thrashing the database by opening and closing rapidly
handler = new Handler();
reportQueue = Collections.synchronizedList(new ArrayList<>());
downloads = Collections.synchronizedList(new ArrayList<>());
@ -335,6 +337,7 @@ public class DownloadService extends Service {
// start auto download in case anything new has shown up
DBTasks.autodownloadUndownloadedItems(getApplicationContext());
PodDBAdapter.getInstance().close();
}
private void setupNotificationBuilders() {