fixed: a small problem in mountparser (it coused core dumped when there was a wrong mount point supplied)

fixed: 'default' funtion can take a directory now (there was an error early)


git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@497 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2009-04-20 21:10:31 +00:00
parent e778903dab
commit e94ccc86f8
4 changed files with 54 additions and 25 deletions

View File

@ -70,6 +70,7 @@ class Content
void PostFunEmacsEdit(bool with_url);
void PostFunEmacs();
void PostFunMkdir(bool add_to_dir_table = false);
long PostFunDefaultParsePath();
void PostFunDefault();
void PostFunPriv();
void PostFunCreateThread();

View File

@ -13,12 +13,56 @@
long Content::PostFunDefaultParsePath()
{
Item * pdir, * pdir2;
long defaultid = -1;
std::string & path = request.PostVar("defaultitem");
if( !path.empty() )
{
std::string dir, file;
Dirs::SplitPath(path, dir, file);
pdir = data.dirs.GetDir(dir);
if( !pdir )
throw Error(Error::incorrect_dir);
if( file.empty() )
{
defaultid = pdir->id;
}
else
{
// checking whether the file is a directory too (the method SplitPath does not check it)
pdir2 = data.dirs.GetDir(file, pdir->id);
if( !pdir2 )
{
defaultid = db.GetFileId(pdir->id, file);
if( defaultid == -1 )
throw Error(Error::db_no_item);
}
else
{
// file is a directory
defaultid = pdir2->id;
}
}
}
return defaultid;
}
void Content::PostFunDefault()
{
Item * pdir;
long fileid = -1;
request.session->done = Done::defaulted_dir;
@ -27,31 +71,15 @@ long fileid = -1;
request.status = Error::permision_denied;
return;
}
try
{
std::string & path = request.PostVar("defaultitem");
if( !path.empty() )
{
std::string dir, file;
Dirs::SplitPath(path, dir, file);
pdir = data.dirs.GetDir(dir);
if( !pdir )
throw Error(Error::incorrect_dir);
fileid = db.GetFileId(pdir->id, file);
if( fileid == -1 )
throw Error(Error::db_no_item);
}
request.session->done_status = db.EditDefaultItem(request.dir_table.back()->id, fileid);
long defaultid = PostFunDefaultParsePath();
request.session->done_status = db.EditDefaultItem(request.dir_table.back()->id, defaultid);
if( request.session->done_status == Error::ok )
request.dir_table.back()->default_item = fileid;
request.dir_table.back()->default_item = defaultid;
}
catch(const Error & e)
{

View File

@ -92,7 +92,7 @@ void MountParser::ReadMountPoint()
}
else
{
err == Error::no_mountpoint;
err = Error::no_mountpoint;
log << log1 << "MP: there is no such a mount point: " << temp << logend;
}
}

View File

@ -16,7 +16,7 @@ void Mounts::ReadMounts()
MountParser mp;
// !! tymczasowo - bedzie odczyt z bazy z /etc/fstab
std::string temp = "thread /forum";
std::string temp = "thread /news";
Error err = mp.Parse(temp, mount_table);