fixed: plugin ticket: when a session expires all files from editticket were removed

it should be removed only those new added


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@798 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-01-21 12:29:44 +00:00
parent 4311f06ade
commit c9931da5ba
11 changed files with 174 additions and 54 deletions

View File

@@ -28,9 +28,21 @@ struct SessionData : public PluginDataBase
SessionData();
~SessionData();
struct SpacePair
{
PT::Space new_space;
PT::Space old_space;
// old_space is used when editing an existing ticket
// current ticket space is copied to old_space
// and when the session expires only new added files
// are deleted
};
virtual void Clear();
typedef std::map<long, Ticket> TicketMap;
typedef std::map<long, PT::Space> SpaceMap;
typedef std::map<long, SpacePair> SpaceMap;
// temporary tickets for 'createticket' function
@@ -54,21 +66,21 @@ struct SessionData : public PluginDataBase
// inserting and returning a new ticket or just returning the ticket if it exists
Ticket & GetTicket(long id, TicketMap & ticket_map, bool * is_new = 0);
// inserting and returning a new space or just returning the space if it exists
PT::Space & GetSpace(long id, SpaceMap & space_map, bool * is_new = 0);
// inserting and returning a new/old space or just returning the space if it exists
PT::Space & GetOldSpace(long id, SpaceMap & space_map, bool * is_new = 0);
PT::Space & GetNewSpace(long id, SpaceMap & space_map, bool * is_new = 0);
// for deleting files
// !! IMPROVE ME: when the program exits there can be a situation that
// fun_rm was finished and then an object of this class exits and call fun_rm
// so we should guarantee that all sessions object are removed first
Fun::Rm * fun_rm;
void RemoveFiles(SpaceMap & space_map);
private:
void RemoveFiles(PT::Space & space);
void RemoveFiles(SpaceMap & space_map, bool only_stale_files);
void RemoveAllFiles(PT::Space & new_space);
void RemoveAllStaleFiles(PT::Space & new_space, PT::Space & old_space);
void BuildFileList(std::vector<long> & file_tab, PT::Space & space);
void CheckFile(std::vector<long> & file_tab, PT::Space & space);
};