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 long size;
protected int statusMsg; protected int statusMsg;
protected boolean done; protected boolean done;
protected boolean cancelled;
public DownloadStatus(FeedFile feedfile, String title) { public DownloadStatus(FeedFile feedfile, String title) {
this.feedfile = feedfile; this.feedfile = feedfile;
@ -58,9 +59,9 @@ public class DownloadStatus {
} }
/** Constructor for restoring Download status entries from DB. */ /** Constructor for restoring Download status entries from DB. */
public DownloadStatus(long id, String title, FeedFile feedfile, int feedfileType, public DownloadStatus(long id, String title, FeedFile feedfile,
boolean successful, int reason, Date completionDate, int feedfileType, boolean successful, int reason,
String reasonDetailed) { Date completionDate, String reasonDetailed) {
progressPercent = 100; progressPercent = 100;
soFar = 0; soFar = 0;
size = 0; size = 0;
@ -79,7 +80,8 @@ public class DownloadStatus {
/** Constructor for creating new completed downloads. */ /** Constructor for creating new completed downloads. */
public DownloadStatus(FeedFile feedfile, String title, int reason, public DownloadStatus(FeedFile feedfile, String title, int reason,
boolean successful, String reasonDetailed) { 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() { public FeedFile getFeedFile() {
@ -174,4 +176,12 @@ public class DownloadStatus {
return feedfileType; 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); FeedFile feedfile = requester.getDownload(request.source);
if (feedfile != null) { if (feedfile != null) {
DownloadStatus status = new DownloadStatus(feedfile, feedfile.getHumanReadableIdentifier()); DownloadStatus status = new DownloadStatus(feedfile,
feedfile.getHumanReadableIdentifier());
Downloader downloader = getDownloader(status); Downloader downloader = getDownloader(status);
if (downloader != null) { if (downloader != null) {
downloads.add(downloader); downloads.add(downloader);
@ -325,7 +326,6 @@ public class DownloadService extends Service {
DownloadStatus status = downloader.getStatus(); DownloadStatus status = downloader.getStatus();
status.setCompletionDate(new Date()); status.setCompletionDate(new Date());
boolean successful = status.isSuccessful(); boolean successful = status.isSuccessful();
int reason = status.getReason();
FeedFile download = status.getFeedFile(); FeedFile download = status.getFeedFile();
if (download != null) { if (download != null) {
@ -338,13 +338,12 @@ public class DownloadService extends Service {
handleCompletedFeedMediaDownload(status); handleCompletedFeedMediaDownload(status);
} }
} else { } else {
if (!successful
&& reason != DownloadError.ERROR_DOWNLOAD_CANCELLED) {
Log.e(TAG, "Download failed");
}
download.setFile_url(null); download.setFile_url(null);
download.setDownloaded(false); download.setDownloaded(false);
if (!successful && !status.isCancelled()) {
Log.e(TAG, "Download failed");
saveDownloadStatus(status); saveDownloadStatus(status);
}
sendDownloadHandledIntent(getDownloadType(download)); sendDownloadHandledIntent(getDownloadType(download));
downloadsBeingHandled -= 1; downloadsBeingHandled -= 1;
} }
@ -428,7 +427,7 @@ public class DownloadService extends Service {
createReport = true; createReport = true;
} }
successfulDownloads++; successfulDownloads++;
} else { } else if (!status.isCancelled()){
if (status.getFeedFile().getClass() != FeedImage.class) { if (status.getFeedFile().getClass() != FeedImage.class) {
createReport = true; createReport = true;
} }

View File

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