removed from Item: update() and save() methods which take the 'url_was_changed' argument

and added ItemModelData (based on morm::ModelData) class which has 'prepare_unique_url' field,
an object of this class is passed to update(), insert() and save() methods

fixed: Dirs::CheckRootDir(): update should update childs too (privileges)

WIP: #4
This commit is contained in:
2021-03-08 21:06:50 +01:00
parent ab5c44a2cb
commit 57aad8b454
17 changed files with 121 additions and 128 deletions

View File

@@ -31,7 +31,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <ctime>
#include "dirs.h"
#include "error.h"
#include "notify/notify.h"
@@ -90,8 +91,9 @@ void Dirs::CheckRootDir()
{
i->item_content.privileges = 07555;
log << log1 << "Dirs: there is no access for a root (admin) to the root dir, setting 07555 for the root directory" << logend;
i->update(false, false);
//db->EditPrivById(*i, i->id);
i->item_content.set_connector(model_connector);
i->item_content.date_modification = std::time(nullptr);
i->item_content.save(false);
}
return;
@@ -99,22 +101,20 @@ void Dirs::CheckRootDir()
log << log1 << "Dirs: there is no a root directory in the database (creating one)" << logend;
ItemModelData item_data;
item_data.prepare_unique_url = false;
Item root;
root.set_connector(model_connector);
root.type = Item::dir;
root.parent_id = -1;
root.item_content.user_id = -1;
root.item_content.group_id = -1;
root.item_content.privileges = 07555;
root.item_content.date_creation = std::time(nullptr);
root.item_content.date_modification = root.item_content.date_creation;
// !! upewnic sie ze baza nie zmieni url (gdyby wczesniej juz byl w bazie pusty url)
// !! zrobic jakis wyjatek do wprowadzania roota?
// if( db->AddItem(root) == WINIX_ERR_OK )
// {
// dir_tab.PushBack(root);
// }
if( root.insert() )
if( root.insert(item_data) )
{
dir_tab.PushBack(root);
}