Only write url of media files when starting download

This commit is contained in:
ByteHamster 2017-10-15 16:20:33 +02:00
parent 115268475d
commit 70f9a9f398
1 changed files with 10 additions and 1 deletions

View File

@ -907,7 +907,15 @@ public class DownloadService extends Service {
}
/**
* Creates the destination file and writes FeedMedia File_url directly after starting download
* to make it possible to resume download after the service was killed by the system.
*/
private void writeFileUrl(DownloadRequest request) {
if (request.getFeedfileType() != FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
return;
}
File dest = new File(request.getDestination());
if (!dest.exists()) {
try {
@ -916,7 +924,8 @@ public class DownloadService extends Service {
Log.e(TAG, "Unable to create file");
}
}
if (dest.exists() && request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
if (dest.exists()) {
Log.d(TAG, "Writing file url");
FeedMedia media = DBReader.getFeedMedia(request.getFeedfileId());
if (media == null) {