Excluded cancelled downloads from the download service report and the

download log
This commit is contained in:
daniel oeh 2012-09-21 12:33:55 +02:00
parent b2aed41e8c
commit 0459f91299
3 changed files with 22 additions and 12 deletions

View File

@ -51,6 +51,7 @@ public class DownloadStatus {
protected long size;
protected int statusMsg;
protected boolean done;
protected boolean cancelled;
public DownloadStatus(FeedFile feedfile, String title) {
this.feedfile = feedfile;
@ -58,9 +59,9 @@ public class DownloadStatus {
}
/** Constructor for restoring Download status entries from DB. */
public DownloadStatus(long id, String title, FeedFile feedfile, int feedfileType,
boolean successful, int reason, Date completionDate,
String reasonDetailed) {
public DownloadStatus(long id, String title, FeedFile feedfile,
int feedfileType, boolean successful, int reason,
Date completionDate, String reasonDetailed) {
progressPercent = 100;
soFar = 0;
size = 0;
@ -79,7 +80,8 @@ public class DownloadStatus {
/** Constructor for creating new completed downloads. */
public DownloadStatus(FeedFile feedfile, String title, int reason,
boolean successful, String reasonDetailed) {
this(0, title, feedfile, feedfile.getTypeAsInt(), successful, reason, new Date(), reasonDetailed);
this(0, title, feedfile, feedfile.getTypeAsInt(), successful, reason,
new Date(), reasonDetailed);
}
public FeedFile getFeedFile() {
@ -174,4 +176,12 @@ public class DownloadStatus {
return feedfileType;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@ -281,7 +281,8 @@ public class DownloadService extends Service {
FeedFile feedfile = requester.getDownload(request.source);
if (feedfile != null) {
DownloadStatus status = new DownloadStatus(feedfile, feedfile.getHumanReadableIdentifier());
DownloadStatus status = new DownloadStatus(feedfile,
feedfile.getHumanReadableIdentifier());
Downloader downloader = getDownloader(status);
if (downloader != null) {
downloads.add(downloader);
@ -325,7 +326,6 @@ public class DownloadService extends Service {
DownloadStatus status = downloader.getStatus();
status.setCompletionDate(new Date());
boolean successful = status.isSuccessful();
int reason = status.getReason();
FeedFile download = status.getFeedFile();
if (download != null) {
@ -338,13 +338,12 @@ public class DownloadService extends Service {
handleCompletedFeedMediaDownload(status);
}
} else {
if (!successful
&& reason != DownloadError.ERROR_DOWNLOAD_CANCELLED) {
Log.e(TAG, "Download failed");
}
download.setFile_url(null);
download.setDownloaded(false);
if (!successful && !status.isCancelled()) {
Log.e(TAG, "Download failed");
saveDownloadStatus(status);
}
sendDownloadHandledIntent(getDownloadType(download));
downloadsBeingHandled -= 1;
}
@ -428,7 +427,7 @@ public class DownloadService extends Service {
createReport = true;
}
successfulDownloads++;
} else {
} else if (!status.isCancelled()){
if (status.getFeedFile().getClass() != FeedImage.class) {
createReport = true;
}

View File

@ -133,6 +133,7 @@ public class HttpDownloader extends Downloader {
status.setReason(DownloadError.ERROR_DOWNLOAD_CANCELLED);
status.setDone(true);
status.setSuccessful(false);
status.setCancelled(true);
}
}