summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-11-21 17:07:28 +0100
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-11-21 17:07:28 +0100
commitaebf2281bfd0b90d074fb9ca5d88b2bea29a518d (patch)
tree63ac368f0cfee91f010972cd447c9ca9768ff7be /src
parent0ea0394709d7e4e1693992fa29389ad84605dbcf (diff)
rest: allow creation of folder with same name in different nodes
Check the parent node along with the folder name to identify if the folder already exists. Fix error when using a folder name defined in any other folder.
Diffstat (limited to 'src')
-rw-r--r--src/rest.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/rest.c b/src/rest.c
index 2539a49..ed8c36d 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -2357,8 +2357,9 @@ static int add_room_folder(struct og_dbi *dbi, struct og_folder *folder)
const char *msglog;
result = dbi_conn_queryf(dbi->conn,
- "SELECT nombregrupo FROM grupos WHERE nombregrupo='%s'",
- folder->name);
+ "SELECT nombregrupo FROM grupos WHERE "
+ "nombregrupo='%s' AND idcentro=%u",
+ folder->name, folder->center);
if (!result) {
dbi_conn_error(dbi->conn, &msglog);
@@ -2400,9 +2401,9 @@ static int add_computer_folder(struct og_dbi *dbi, struct og_folder *folder)
const char *msglog;
result = dbi_conn_queryf(dbi->conn,
- "SELECT nombregrupoordenador FROM gruposordenadores WHERE nombregrupoordenador='%s'",
- folder->name);
-
+ "SELECT nombregrupoordenador FROM gruposordenadores WHERE "
+ "nombregrupoordenador='%s' AND idaula=%u",
+ folder->name, folder->room);
if (!result) {
dbi_conn_error(dbi->conn, &msglog);
syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",