summaryrefslogtreecommitdiff
path: root/firmware/common
diff options
context:
space:
mode:
authorBoris Gjenero <boris.gjenero@gmail.com>2017-03-08 22:38:09 -0500
committerMichael Sevakis <jethead71@rockbox.org>2017-03-21 21:04:36 -0400
commit05739efe8d9df2a83b983a86d07cb0715c6d19ee (patch)
tree8b94d917f8b788ea56dcb28d9d069a1e64a6766d /firmware/common
parent35d69c80a609d5533ad2ee0386bcdbc1a1f12443 (diff)
downloadrockbox-05739efe8d9df2a83b983a86d07cb0715c6d19ee.tar.gz
rockbox-05739efe8d9df2a83b983a86d07cb0715c6d19ee.zip
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
Diffstat (limited to 'firmware/common')
-rw-r--r--firmware/common/dircache.c10
1 files changed, 6 insertions, 4 deletions
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)
1884 dircache.reserve_used = reserve_used; 1884 dircache.reserve_used = reserve_used;
1885 1885
1886 if (DIRCACHE_STUFFED(reserve_used)) 1886 if (DIRCACHE_STUFFED(reserve_used))
1887 dircache.last_size = 0; /* reset */ 1887 dircache.last_size = 0; /* reset */
1888 else if (dircache.size > dircache.last_size || 1888 else if (dircache.size > dircache.last_size)
1889 dircache.last_size - dircache.size > DIRCACHE_RESERVE) 1889 dircache.last_size = dircache.size; /* grow */
1890 dircache.last_size = dircache.size; 1890 else if (!dircache_runinfo.suspended &&
1891 dircache.last_size - dircache.size > DIRCACHE_RESERVE)
1892 dircache.last_size = dircache.size; /* shrink if not suspended */
1891 1893
1892 logf("Done, %ld KiB used", dircache.size / 1024); 1894 logf("Done, %ld KiB used", dircache.size / 1024);
1893 1895