From beecac49da738d164ef524332224a6700791aa1e Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Fri, 13 Aug 2010 09:41:21 -0700 Subject: remove shadowed variable declaration An accidental variable declaration ("int enough_space = ..." instead of "enough_space = " inside a block) shadowing the real one meant we were always using the copy-to-cache path for patching, even when not necessary. Remove it. Enforce an absolute minimum of free space as well, to avoid running into problems patching small files, now that the copy-to-cache path is (inadvertently) well-tested. Change-Id: Idb7d57241a9adcda2e11001fa44f0cd67ce40d19 --- applypatch/applypatch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 99d366165..3c816c52e 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -645,7 +645,8 @@ int applypatch(const char* source_filename, int enough_space = 0; if (retry > 0) { size_t free_space = FreeSpaceForFile(target_fs); - int enough_space = + 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); -- cgit v1.2.3 From dff87121ad861dc830fc96823725b466d80d1110 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 12 Aug 2010 17:38:09 -0700 Subject: fix bug in applying patches When restarting a patch from crashing in the middle of a large file, we're not finding the correct patch to apply to the copy saved in cache. Change-Id: I41cb2b87d096bb7a28a10c4cf3902facd45d4c9d --- applypatch/applypatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 3c816c52e..b85b91592 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -588,7 +588,7 @@ int applypatch(const char* source_filename, int to_use = FindMatchingPatch(copy_file.sha1, patch_sha1_str, num_patches); - if (to_use > 0) { + if (to_use >= 0) { copy_patch_value = patch_data[to_use]; } -- cgit v1.2.3