1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From 14e8ab28d374b5ee748dbef362995764683abec8 Mon Sep 17 00:00:00 2001
From: Thomas Jarosch <[email protected]>
Date: Sat, 1 Jan 2011 14:06:19 +0100
Subject: [PATCH] RaaA: Fix database duplication issue on every start

The code in tagcache.c:commit() was unable to delete
the to-be-commited database file as it read from
$(HOME)/.config/rockbox.org and tried to delete
the file later on in /.rockbox/.

As we didn't specify any flags like IS_FILE or NEED_WRITE
in _get_user_file_path() (which is called by f.e. app_remove()),
it searched for the file in two places.

In case of app_rename() IS_FILE would be wrong, so we just
add a NEED_WRITE to any write operation.

---
 firmware/common/rbpaths.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/firmware/common/rbpaths.c b/firmware/common/rbpaths.c
index 8dcaa35..cbaa3cc 100644
--- a/firmware/common/rbpaths.c
+++ b/firmware/common/rbpaths.c
@@ -165,8 +165,9 @@ int app_remove(const char *name)
     const char *fname = name;
     if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
     {
-        fname = _get_user_file_path(name, 0, realpath, sizeof(realpath));
+        fname = _get_user_file_path(name, NEED_WRITE, realpath, sizeof(realpath));
     }
+
     return remove(fname);
 }

@@ -176,7 +177,7 @@ int app_rename(const char *old, const char *new)
     const char *fname = old;
     if (!strncmp(ROCKBOX_DIR, old, ROCKBOX_DIR_LEN))
     {
-        fname = _get_user_file_path(old, 0, realpath, sizeof(realpath));
+        fname = _get_user_file_path(old, NEED_WRITE, realpath, sizeof(realpath));
     }
     return rename(fname, new);
 }
@@ -212,7 +213,7 @@ int app_mkdir(const char* name)
     const char *fname = name;
     if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
     {
-        fname = _get_user_file_path(name, 0, realpath, sizeof(realpath));
+        fname = _get_user_file_path(name, NEED_WRITE, realpath, sizeof(realpath));
     }
     return mkdir(fname);
 }
@@ -223,8 +224,7 @@ int app_rmdir(const char* name)
     const char *fname = name;
     if (!strncmp(ROCKBOX_DIR, name, ROCKBOX_DIR_LEN))
     {
-        fname = _get_user_file_path(name, 0, realpath, sizeof(realpath));
+        fname = _get_user_file_path(name, NEED_WRITE, realpath, sizeof(realpath));
     }
     return rmdir(fname);
 }
-
-- 
1.7.3.5