new option database-root
[adu.git] / create.c
index d08da1c026909de78ccd4386d22d9545de139c80..87b0b9a0198a471e0a5a886dbce84a09c49f4901 100644 (file)
--- a/create.c
+++ b/create.c
@@ -4,7 +4,7 @@
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
-/** \file create.c The create mode of adu. */
+/** \file create.c \brief The create mode of adu. */
 
 #include <dirent.h> /* readdir() */
 #include "format.h"
@@ -58,9 +58,7 @@ static int update_user_row(struct osl_table *t, uint64_t dir_num,
                objects[UT_BYTES].size = sizeof(*add);
                objects[UT_FILES].data = &num_files;
                objects[UT_FILES].size = sizeof(num_files);
-               INFO_LOG("######################### ret: %d\n", ret);
                ret = osl(osl_add_row(t, objects));
-               INFO_LOG("######################### ret: %d\n", ret);
                return ret;
        } else { /* add size and increment file count */
                uint64_t num;
@@ -133,11 +131,9 @@ static int scan_dir(char *dirname, uint64_t *parent_dir_num)
                dir_size += size;
                dir_files++;
                uid = s.st_uid;
-               ret = search_uid(uid, NULL, CREATE_USER_TABLE | OPEN_USER_TABLE, &ui);
+               ret = create_user_table(uid, &ui);
                if (ret < 0)
                        goto out;
-               ui->bytes += size;
-               ui->files++;
                ret = update_user_row(ui->table, this_dir_num, &size);
                if (ret < 0)
                        goto out;
@@ -153,6 +149,11 @@ out:
        return ret;
 }
 
+/**
+ * The main function of the create mode.
+ *
+ * \return Standard.
+ */
 int com_create(void)
 {
        uint64_t zero = 0ULL;
@@ -174,6 +175,5 @@ int com_create(void)
                goto out;
        ret = write_uid_file();
 out:
-       close_all_tables();
        return ret;
 }