From 05739efe8d9df2a83b983a86d07cb0715c6d19ee Mon Sep 17 00:00:00 2001 From: Boris Gjenero Date: Wed, 8 Mar 2017 22:38:09 -0500 Subject: Avoid having to wait for dircache builds if shut down too soon When dircache scanning is happening in the background, the user can shut down the device before it is complete. Then, reset_cache() sets size to 0 before it is copied to last_size at the end of build_volumes(). When saved last_size is zero, scanning happens in the foreground during next startup. Avoid shrinking the size if the build is suspended. Change-Id: Ife133e0be0dc0dfd53a4de119f70dba014c7ee68 --- firmware/common/dircache.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'firmware/common') diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index 42585e121b..e8f149cad0 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c @@ -1884,10 +1884,12 @@ static void build_volumes(void) dircache.reserve_used = reserve_used; if (DIRCACHE_STUFFED(reserve_used)) - dircache.last_size = 0; /* reset */ - else if (dircache.size > dircache.last_size || - dircache.last_size - dircache.size > DIRCACHE_RESERVE) - dircache.last_size = dircache.size; + dircache.last_size = 0; /* reset */ + else if (dircache.size > dircache.last_size) + dircache.last_size = dircache.size; /* grow */ + else if (!dircache_runinfo.suspended && + dircache.last_size - dircache.size > DIRCACHE_RESERVE) + dircache.last_size = dircache.size; /* shrink if not suspended */ logf("Done, %ld KiB used", dircache.size / 1024); -- cgit v1.2.3