reduce some recovery logging

Make minzip log only a count of files when extracting, not individual
filenames.  Make patching only chatter about free space if there's not
enough and compact the other messages.

Only the last 8k of the recovery log gets uploaded; this makes it more
likely that we will get all of it.

Change-Id: I529cb4947fe2185df82b9da5fae450a7480dcecd
This commit is contained in:
Doug Zongker
2012-10-19 12:24:26 -07:00
parent a0d9ddb8f2
commit bf80f49edc
2 changed files with 26 additions and 7 deletions
+21 -6
View File
@@ -585,6 +585,14 @@ int CacheSizeCheck(size_t bytes) {
}
}
static void print_short_sha1(const uint8_t sha1[SHA_DIGEST_SIZE]) {
int i;
const char* hex = "0123456789abcdef";
for (i = 0; i < 4; ++i) {
putchar(hex[(sha1[i]>>4) & 0xf]);
putchar(hex[sha1[i] & 0xf]);
}
}
// This function applies binary patches to files in a way that is safe
// (the original file is not touched until we have the desired
@@ -620,7 +628,7 @@ int applypatch(const char* source_filename,
char** const patch_sha1_str,
Value** patch_data,
Value* bonus_data) {
printf("\napplying patch to %s\n", source_filename);
printf("patch %s: ", source_filename);
if (target_filename[0] == '-' &&
target_filename[1] == '\0') {
@@ -646,8 +654,9 @@ int applypatch(const char* source_filename,
if (memcmp(source_file.sha1, target_sha1, SHA_DIGEST_SIZE) == 0) {
// The early-exit case: the patch was already applied, this file
// has the desired hash, nothing for us to do.
printf("\"%s\" is already target; no patch needed\n",
target_filename);
printf("already ");
print_short_sha1(target_sha1);
putchar('\n');
free(source_file.data);
return 0;
}
@@ -769,8 +778,10 @@ static int GenerateTarget(FileContents* source_file,
enough_space =
(free_space > (256 << 10)) && // 256k (two-block) minimum
(free_space > (target_size * 3 / 2)); // 50% margin of error
printf("target %ld bytes; free space %ld bytes; retry %d; enough %d\n",
(long)target_size, (long)free_space, retry, enough_space);
if (!enough_space) {
printf("target %ld bytes; free space %ld bytes; retry %d; enough %d\n",
(long)target_size, (long)free_space, retry, enough_space);
}
}
if (!enough_space) {
@@ -805,7 +816,7 @@ static int GenerateTarget(FileContents* source_file,
unlink(source_filename);
size_t free_space = FreeSpaceForFile(target_fs);
printf("(now %ld bytes free for target)\n", (long)free_space);
printf("(now %ld bytes free for target) ", (long)free_space);
}
}
@@ -901,6 +912,10 @@ static int GenerateTarget(FileContents* source_file,
if (memcmp(current_target_sha1, target_sha1, SHA_DIGEST_SIZE) != 0) {
printf("patch did not produce expected sha1\n");
return 1;
} else {
printf("now ");
print_short_sha1(target_sha1);
putchar('\n');
}
if (output < 0) {
+5 -1
View File
@@ -985,6 +985,7 @@ bool mzExtractRecursive(const ZipArchive *pArchive,
unsigned int i;
bool seenMatch = false;
int ok = true;
int extractCount = 0;
for (i = 0; i < pArchive->numEntries; i++) {
ZipEntry *pEntry = pArchive->pEntries + i;
if (pEntry->fileNameLen < zipDirLen) {
@@ -1150,13 +1151,16 @@ bool mzExtractRecursive(const ZipArchive *pArchive,
break;
}
LOGD("Extracted file \"%s\"\n", targetFile);
LOGV("Extracted file \"%s\"\n", targetFile);
++extractCount;
}
}
if (callback != NULL) callback(targetFile, cookie);
}
LOGD("Extracted %d file(s)\n", extractCount);
free(helper.buf);
free(zpath);