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
diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c
index 7b8a010..69f8633 100644
--- a/applypatch/applypatch.c
+++ b/applypatch/applypatch.c
@@ -585,6 +585,14 @@
}
}
+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 @@
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 @@
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 @@
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 @@
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 @@
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) {
diff --git a/minzip/Zip.c b/minzip/Zip.c
index c87f038..439e5d9 100644
--- a/minzip/Zip.c
+++ b/minzip/Zip.c
@@ -985,6 +985,7 @@
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 @@
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);