mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 785124 - Pt 3 - Modify the updater to support update.link file. r=rstrong
From 76c70c31f5362f7c91d567ca04329195d8126f26 Mon Sep 17 00:00:00 2001 file. Prefer sdcard for download --- toolkit/mozapps/update/updater/updater.cpp | 53 +++++++++++++++++++++++++--- toolkit/xre/nsUpdateDriver.cpp | 13 +++++-- 2 files changed, 60 insertions(+), 6 deletions(-)
This commit is contained in:
parent
a4b95968d1
commit
6e678052db
@ -2085,6 +2085,50 @@ ReadMARChannelIDs(const NS_tchar *path, MARChannelStringTable *results)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
GetUpdateFileName(NS_tchar *fileName, int maxChars)
|
||||
{
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
// If an update.link file exists, then it will contain the name
|
||||
// of the update file (terminated by a newline).
|
||||
|
||||
NS_tchar linkFileName[MAXPATHLEN];
|
||||
NS_tsnprintf(linkFileName, sizeof(linkFileName)/sizeof(linkFileName[0]),
|
||||
NS_T("%s/update.link"), gSourcePath);
|
||||
AutoFile linkFile = NS_tfopen(linkFileName, NS_T("rb"));
|
||||
if (linkFile == NULL) {
|
||||
NS_tsnprintf(fileName, maxChars,
|
||||
NS_T("%s/update.mar"), gSourcePath);
|
||||
return OK;
|
||||
}
|
||||
|
||||
char dataFileName[MAXPATHLEN];
|
||||
size_t bytesRead;
|
||||
|
||||
if ((bytesRead = fread(dataFileName, 1, sizeof(dataFileName)-1, linkFile)) <= 0) {
|
||||
*fileName = NS_T('\0');
|
||||
return READ_ERROR;
|
||||
}
|
||||
if (dataFileName[bytesRead-1] == '\n') {
|
||||
// Strip trailing newline (for \n and \r\n)
|
||||
bytesRead--;
|
||||
}
|
||||
if (dataFileName[bytesRead-1] == '\r') {
|
||||
// Strip trailing CR (for \r, \r\n)
|
||||
bytesRead--;
|
||||
}
|
||||
dataFileName[bytesRead] = '\0';
|
||||
|
||||
strncpy(fileName, dataFileName, maxChars-1);
|
||||
fileName[maxChars-1] = '\0';
|
||||
#else
|
||||
// We currently only support update.link files under GONK
|
||||
NS_tsnprintf(fileName, maxChars,
|
||||
NS_T("%s/update.mar"), gSourcePath);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
static void
|
||||
UpdateThreadFunc(void *param)
|
||||
{
|
||||
@ -2094,10 +2138,10 @@ UpdateThreadFunc(void *param)
|
||||
rv = ProcessReplaceRequest();
|
||||
} else {
|
||||
NS_tchar dataFile[MAXPATHLEN];
|
||||
NS_tsnprintf(dataFile, sizeof(dataFile)/sizeof(dataFile[0]),
|
||||
NS_T("%s/update.mar"), gSourcePath);
|
||||
|
||||
rv = gArchiveReader.Open(dataFile);
|
||||
rv = GetUpdateFileName(dataFile, sizeof(dataFile)/sizeof(dataFile[0]));
|
||||
if (rv == OK) {
|
||||
rv = gArchiveReader.Open(dataFile);
|
||||
}
|
||||
|
||||
#ifdef MOZ_VERIFY_MAR_SIGNATURE
|
||||
if (rv == OK) {
|
||||
|
@ -987,8 +987,17 @@ nsUpdateProcessor::ProcessUpdate(nsIUpdate* aUpdate)
|
||||
if (dirProvider) { // Normal code path
|
||||
// Check for and process any available updates
|
||||
bool persistent;
|
||||
nsresult rv = dirProvider->GetFile(XRE_UPDATE_ROOT_DIR, &persistent,
|
||||
getter_AddRefs(updRoot));
|
||||
nsresult rv = NS_ERROR_FAILURE; // Take the NS_FAILED path when non-GONK
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
// Check in the sdcard for updates first, since that's our preferred
|
||||
// download location.
|
||||
rv = dirProvider->GetFile(XRE_UPDATE_ARCHIVE_DIR, &persistent,
|
||||
getter_AddRefs(updRoot));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = dirProvider->GetFile(XRE_UPDATE_ROOT_DIR, &persistent,
|
||||
getter_AddRefs(updRoot));
|
||||
}
|
||||
// XRE_UPDATE_ROOT_DIR may fail. Fallback to appDir if failed
|
||||
if (NS_FAILED(rv))
|
||||
updRoot = dirProvider->GetAppDir();
|
||||
|
@ -123,6 +123,14 @@
|
||||
*/
|
||||
#define XRE_UPDATE_ROOT_DIR "UpdRootD"
|
||||
|
||||
/**
|
||||
* A directory service key which provides an alternate location
|
||||
* to UpdRootD to to store large files. This key is currently
|
||||
* only implemented in the Gonk directory service provider.
|
||||
*/
|
||||
|
||||
#define XRE_UPDATE_ARCHIVE_DIR "UpdArchD"
|
||||
|
||||
/**
|
||||
* A directory service key which provides the directory where an OS update is
|
||||
* applied.
|
||||
|
Loading…
Reference in New Issue
Block a user