CmdEdit: Do not allow concurrent edits

This commit is contained in:
Tomas Babej 2015-09-16 20:31:59 +02:00 committed by Paul Beckingham
parent 9ef8c1aeba
commit 45dea75faa
10 changed files with 15 additions and 1 deletions

View file

@ -756,7 +756,7 @@ CmdEdit::editResult CmdEdit::editFile (Task& task)
// Create a temp file name in data.location.
std::stringstream file;
file << "task." << getpid () << "." << task.id << ".task";
file << "task." << task.get ("uuid").substr (0, 8) << ".task";
// Determine the output date format, which uses a hierarchy of definitions.
// rc.dateformat.edit
@ -770,6 +770,11 @@ CmdEdit::editResult CmdEdit::editFile (Task& task)
int ignored = chdir (location._data.c_str ());
++ignored; // Keep compiler quiet.
// Check if the file already exists, if so, bail out
Path filepath = Path (file.str ());
if (filepath.exists ())
throw std::string (STRING_EDIT_IN_PROGRESS);
// Format the contents, T -> text, write to a file.
std::string before = formatTask (task, dateformat);
std::string before_orig = before;