mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 04:27:20 +02:00
CmdEdit: Do not allow concurrent edits
This commit is contained in:
parent
9ef8c1aeba
commit
45dea75faa
10 changed files with 15 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue