New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TW-1702] On-modify hook script only partially modifies other task #1726
Comments
Migrated metadata:
|
Paul Beckingham on 2015-09-19T19:20:16Z says: I have asked subject matter experts to jump in. |
Wim Schuermann on 2015-09-20T17:30:51Z says: This is a known problem with the current approach. In a nutshell, here's what happens: The Taskwarrior instance you call (T1) calls the on-modify hook (H1), which in turn calls a second Taskwarrior instance (T2) which modifies other tasks.
You can probably spot the problem - T1 and T2 read the same data, but write different data. T2's changes get overwritten by T1's changes. What you call a hook script "partially modifying" tasks stems from the fact that undo.data is appended to during changes, meaning that T2's modifications are logged in undo.data despite the actual changes to pending.data being overwritten by T1 later on. In order to prevent this, Taskwarrior would have to lock the data files before calling on-modify (and possibly on-add) hooks. In the meantime, there probably needs to be a bigger "DO NOT TRY TO CALL TASKWARRIOR FROM HOOK SCRIPTS IF YOU DON'T KNOW WHAT YOU'RE DOING" warning. Still, it's not an ideal situation. If you want to work around this, take a look at the "blocks attribute" hook on [http://taskwarrior.org/tools/#hooks] to see one way of dealing with this. It writes changes to other tasks to a file that is read by an on-launch hook the next time Taskwarrior is run. |
Paul Beckingham on 2015-09-20T19:28:43Z says: How about T1 runs the on-modify hook and writes commands ( |
Wim Schuermann on 2015-09-20T19:48:17Z says: I explained this in #taskwarrior after you asked, but didn't preface it with your name. I'll copy&paste here because it's probably worth mentioning it:
If you don't care about error handling and are willing to drop modifications that lead to problems, then an on-exit hook is fine of course. |
Robin Green on 2015-09-19T18:43:02Z says:
I have written an on-modify hook which ask the user what to do if due dates are inconsistent with due dates of dependencies, and if the user so requests, either tries to modify the due dates of the current task, or of the dependencies.
This hook seems to work when the user opts to modify the current task, but after I launch
task modify
from the hook to modify a dependency, the change history intask info
shows the due date as having been changed, but the due date shown in the output of the very sametask info
command shows that the due date has not in fact been changed, contrary to the change history.The text was updated successfully, but these errors were encountered: