summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/tagcache.c19
-rw-r--r--firmware/common/dircache.c5
2 files changed, 21 insertions, 3 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 98beba9b58..866b5c1444 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -1832,6 +1832,10 @@ static bool commit(void)
1832 int i, len, rc; 1832 int i, len, rc;
1833 int tmpfd; 1833 int tmpfd;
1834 int masterfd; 1834 int masterfd;
1835#ifdef HAVE_DIRCACHE
1836 bool dircache_buffer_stolen = false;
1837#endif
1838 bool local_allocation = false;
1835 1839
1836 logf("committing tagcache"); 1840 logf("committing tagcache");
1837 1841
@@ -1864,12 +1868,18 @@ static bool commit(void)
1864 } 1868 }
1865 1869
1866 /* Try to steal every buffer we can :) */ 1870 /* Try to steal every buffer we can :) */
1871 if (tempbuf_size == 0)
1872 local_allocation = true;
1873
1867#ifdef HAVE_DIRCACHE 1874#ifdef HAVE_DIRCACHE
1868 if (tempbuf_size == 0) 1875 if (tempbuf_size == 0)
1869 { 1876 {
1870 /* Try to steal the dircache buffer. */ 1877 /* Try to steal the dircache buffer. */
1871 tempbuf = dircache_steal_buffer(&tempbuf_size); 1878 tempbuf = dircache_steal_buffer(&tempbuf_size);
1872 tempbuf_size &= ~0x03; 1879 tempbuf_size &= ~0x03;
1880
1881 if (tempbuf_size > 0)
1882 dircache_buffer_stolen = true;
1873 } 1883 }
1874#endif 1884#endif
1875 1885
@@ -1956,9 +1966,16 @@ static bool commit(void)
1956 logf("tagcache committed"); 1966 logf("tagcache committed");
1957 remove(TAGCACHE_FILE_TEMP); 1967 remove(TAGCACHE_FILE_TEMP);
1958 1968
1969 if (local_allocation)
1970 {
1971 tempbuf = NULL;
1972 tempbuf_size = 0;
1973 }
1974
1959#ifdef HAVE_DIRCACHE 1975#ifdef HAVE_DIRCACHE
1960 /* Rebuild the dircache, if we stole the buffer. */ 1976 /* Rebuild the dircache, if we stole the buffer. */
1961 dircache_build(0); 1977 if (dircache_buffer_stolen)
1978 dircache_build(0);
1962#endif 1979#endif
1963 1980
1964#ifdef HAVE_TC_RAMCACHE 1981#ifdef HAVE_TC_RAMCACHE
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index e5ee77c311..e1b592f005 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -37,13 +37,12 @@
37#include "kernel.h" 37#include "kernel.h"
38#include "usb.h" 38#include "usb.h"
39#include "file.h" 39#include "file.h"
40#include "buffer.h"
40 41
41/* Queue commands. */ 42/* Queue commands. */
42#define DIRCACHE_BUILD 1 43#define DIRCACHE_BUILD 1
43#define DIRCACHE_STOP 2 44#define DIRCACHE_STOP 2
44 45
45extern char *audiobuf;
46
47#define MAX_OPEN_DIRS 8 46#define MAX_OPEN_DIRS 8
48DIRCACHED opendirs[MAX_OPEN_DIRS]; 47DIRCACHED opendirs[MAX_OPEN_DIRS];
49 48
@@ -668,6 +667,8 @@ void dircache_init(void)
668{ 667{
669 int i; 668 int i;
670 669
670 dircache_initialized = false;
671
671 memset(opendirs, 0, sizeof(opendirs)); 672 memset(opendirs, 0, sizeof(opendirs));
672 for (i = 0; i < MAX_OPEN_DIRS; i++) 673 for (i = 0; i < MAX_OPEN_DIRS; i++)
673 { 674 {