Bug 1276588 - Handling Hyphenation-Dictionaries in DownloadAction. r=sebastian

MozReview-Commit-ID: GTuR0IarjGe

--HG--
extra : rebase_source : 3718d249a0413d278b8a5e7d77a77086caafbd9e
This commit is contained in:
Krishna 2016-12-04 23:06:35 +08:00
parent c1f499b304
commit 512218087a
4 changed files with 14 additions and 18 deletions

View File

@ -94,19 +94,21 @@ public abstract class BaseAction {
protected File getDestinationFile(Context context, DownloadContent content)
throws UnrecoverableDownloadContentException, RecoverableDownloadContentException {
File destinationDirectory;
if (content.isFont()) {
File destinationDirectory = new File(context.getApplicationInfo().dataDir, "fonts");
if (!destinationDirectory.exists() && !destinationDirectory.mkdirs()) {
throw new RecoverableDownloadContentException(RecoverableDownloadContentException.DISK_IO,
"Destination directory does not exist and cannot be created");
}
return new File(destinationDirectory, content.getFilename());
destinationDirectory = new File(context.getApplicationInfo().dataDir, "fonts");
} else if (content.isHyphenationDictionary()) {
destinationDirectory = new File(context.getApplicationInfo().dataDir, "hyphenation");
} else {
throw new UnrecoverableDownloadContentException("Can't determine destination for kind: " + content.getKind());
}
// Unrecoverable: We downloaded a file and we don't know what to do with it (Should not happen)
throw new UnrecoverableDownloadContentException("Can't determine destination for kind: " + content.getKind());
if (!destinationDirectory.exists() && !destinationDirectory.mkdirs()) {
throw new RecoverableDownloadContentException(RecoverableDownloadContentException.DISK_IO,
"Destination directory does not exist and cannot be created");
}
return new File(destinationDirectory, content.getFilename());
}
protected boolean verify(File file, String expectedChecksum)

View File

@ -11,10 +11,8 @@ import android.net.NetworkInfo;
import android.support.v4.net.ConnectivityManagerCompat;
import android.util.Log;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.dlc.catalog.DownloadContent;
import org.mozilla.gecko.dlc.catalog.DownloadContentCatalog;
import org.mozilla.gecko.util.HardwareUtils;
import org.mozilla.gecko.util.IOUtils;
import java.io.BufferedInputStream;
@ -27,8 +25,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.zip.GZIPInputStream;
/**
@ -253,8 +249,6 @@ public class DownloadAction extends BaseAction {
}
protected String createDownloadURL(DownloadContent content) {
final String location = content.getLocation();
return CDN_BASE_URL + content.getLocation();
}

View File

@ -29,7 +29,7 @@ public class StudyAction extends BaseAction {
continue;
}
if (content.isAssetArchive() && content.isFont()) {
if (content.isKnownContent()) {
catalog.scheduleDownload(content);
Log.d(LOGTAG, "Scheduled download: " + content);

View File

@ -130,7 +130,7 @@ public class SyncAction extends BaseAction {
}
// Only select the fields we are actually going to read.
builder.appendQueryParameter(KINTO_PARAMETER_FIELDS,
"attachment.location,attachment.original.filename,attachment.original.hash,attachment.hash,type,kind,attachment.original.size,match");
"type,kind,attachment.location,attachment.hash,attachment.original.size,attachment.original.filename,attachment.original.hash,match");
// We want to process items in the order they have been modified. This is to ensure that
// our last_modified values are correct if we processing is interrupted and not all items