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;

View file

@ -671,6 +671,7 @@
#define STRING_EDIT_NO_CHANGES "Keine Änderungen entdeckt."
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
#define STRING_EDIT_COMPLETE "Bearbeitung abgeschlossen."
#define STRING_EDIT_IN_PROGRESS "Task is already being edited."
#define STRING_EDIT_LAUNCHING "Starte jetzt '{1}'..."
#define STRING_EDIT_CHANGES "Änderungen entdeckt."
#define STRING_EDIT_UNPARSEABLE "Taskwarrior konnte Ihre Änderungen nicht verarbeiten. Möchten Sie es erneut probieren?"

View file

@ -669,6 +669,7 @@
#define STRING_EDIT_NO_CHANGES "No edits were detected."
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
#define STRING_EDIT_COMPLETE "Editing complete."
#define STRING_EDIT_IN_PROGRESS "Task is already being edited."
#define STRING_EDIT_LAUNCHING "Launching '{1}' now..."
#define STRING_EDIT_CHANGES "Edits were detected."
#define STRING_EDIT_UNPARSEABLE "Taskwarrior couldn't handle your edits. Would you like to try again?"

View file

@ -671,6 +671,7 @@
#define STRING_EDIT_NO_CHANGES "Ne detektis nenian redakton."
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
#define STRING_EDIT_COMPLETE "Redaktis komplete."
#define STRING_EDIT_IN_PROGRESS "Task is already being edited."
#define STRING_EDIT_LAUNCHING "Lanĉanta nun '{1}'..."
#define STRING_EDIT_CHANGES "Detektis redaktojn."
#define STRING_EDIT_UNPARSEABLE "Taskwarrior ne povis trakti viaj redaktojn. Ĉu vi volas ripovi?"

View file

@ -683,6 +683,7 @@
#define STRING_EDIT_NO_CHANGES "No se detectaron modificaciones."
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
#define STRING_EDIT_COMPLETE "Edición completada."
#define STRING_EDIT_IN_PROGRESS "Task is already being edited."
#define STRING_EDIT_LAUNCHING "Lanzando '{1}' ahora..."
#define STRING_EDIT_CHANGES "Se detectaron modificaciones."
#define STRING_EDIT_UNPARSEABLE "Taskwarrior no pudo manejar sus modificaciones. ¿Quiere intentarlo de nuevo?"

View file

@ -671,6 +671,7 @@
#define STRING_EDIT_NO_CHANGES "Aucunes modifications détectées."
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
#define STRING_EDIT_COMPLETE "Édition terminée."
#define STRING_EDIT_IN_PROGRESS "Task is already being edited."
#define STRING_EDIT_LAUNCHING "Lancement de '{1}' maintenant..."
#define STRING_EDIT_CHANGES "Des modifications ont été détectées."
#define STRING_EDIT_UNPARSEABLE "Taskwarrior n'a pas pu appliquer vos modifications. Désirez-vous essayer à nouveau ?"

View file

@ -670,6 +670,7 @@
#define STRING_EDIT_NO_CHANGES "Nessuna modifica riscontrata."
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
#define STRING_EDIT_COMPLETE "Modifica completa."
#define STRING_EDIT_IN_PROGRESS "Task is already being edited."
#define STRING_EDIT_LAUNCHING "Esecuzione di '{1}' ora..."
#define STRING_EDIT_CHANGES "Modifiche rilevate."
#define STRING_EDIT_UNPARSEABLE "Taskwarrior non può gestire le modifiche. Provare di nuovo?"

View file

@ -671,6 +671,7 @@
#define STRING_EDIT_NO_CHANGES "No edits were detected."
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
#define STRING_EDIT_COMPLETE "Editing complete."
#define STRING_EDIT_IN_PROGRESS "Task is already being edited."
#define STRING_EDIT_LAUNCHING "Launching '{1}' now..."
#define STRING_EDIT_CHANGES "Edits were detected."
#define STRING_EDIT_UNPARSEABLE "Taskwarrior couldn't handle your edits. Would you like to try again?"

View file

@ -671,6 +671,7 @@
#define STRING_EDIT_NO_CHANGES "Nie znaleziono żadnych edycji."
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
#define STRING_EDIT_COMPLETE "Edycja zakończona."
#define STRING_EDIT_IN_PROGRESS "Task is already being edited."
#define STRING_EDIT_LAUNCHING "Uruchamianie '{1}'..."
#define STRING_EDIT_CHANGES "Zmiany wykryte."
#define STRING_EDIT_UNPARSEABLE "Taskwarrior nie może wprowadzić twoich zmian. Czy chcesz spróbować jeszcze raz?"

View file

@ -671,6 +671,7 @@
#define STRING_EDIT_NO_CHANGES "Não foram detetadas alterações."
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
#define STRING_EDIT_COMPLETE "Edição concluída."
#define STRING_EDIT_IN_PROGRESS "Task is already being edited."
#define STRING_EDIT_LAUNCHING "A iniciar '{1}' ..."
#define STRING_EDIT_CHANGES "Alterações detetadas."
#define STRING_EDIT_UNPARSEABLE "O taskwarrior não conseguiu processar as suas alterações. Deseja tentar novamente?"