fix: explicitly recreate deleted task captures
This commit is contained in:
1 parent
bd54b5f06a
commit
e27c023d66
7 files changed
+138
-6
No files matched your search
@@ -32,7 +32,7 @@ import urllib.parse as url
|
||||
import urllib.request as http
|
||||
import webbrowser
|
||||
|
||||
VERSION = '0.4.1'
|
||||
VERSION = '0.4.2'
|
||||
|
||||
class Failure(Exception):
|
||||
def __init__(self, message, status=0, payload=None):
|
||||
@@ -569,7 +569,7 @@ def tasks(client, profile, words):
|
||||
for name in ('done','reopen','archive','start'):
|
||||
p=sub.add_parser(name);p.add_argument('uuid',type=task_uuid)
|
||||
sub.add_parser('stop');sub.add_parser('status')
|
||||
p=sub.add_parser('retry');p.add_argument('request_id',type=task_uuid)
|
||||
p=sub.add_parser('retry');p.add_argument('request_id',type=task_uuid);p.add_argument('--recreate-deleted',action='store_true',help='Explicitly recreate a deleted capture with a new UUID; preserve and relink any existing Wiki page')
|
||||
p=sub.add_parser('report');p.add_argument('--from',dest='start');p.add_argument('--to',dest='end')
|
||||
p=sub.add_parser('preferences');p.add_argument('--wiki-prefix');p.add_argument('--project');p.add_argument('--assignee');p.add_argument('--due-days',type=int);p.add_argument('--start-days',type=int);p.add_argument('--planned-days',type=int);p.add_argument('--review-days',type=int);p.add_argument('--estimate',type=int);p.add_argument('--complexity',type=int);p.add_argument('--digest',choices=['on','off']);p.add_argument('--at');p.add_argument('--timezone')
|
||||
for child in sub.choices.values():child.add_argument('--json',action='store_true')
|
||||
@@ -583,6 +583,14 @@ def tasks(client, profile, words):
|
||||
if replaced:print('Replaced the retained draft with the current input.',file=sys.stderr)
|
||||
try: result=client.json(TASK_API+'capture',method='POST',data=payload)
|
||||
except Failure as e:
|
||||
if e.status==410 and e.payload.get('error')=='deleted':
|
||||
raise Failure('Draft retained. This task was deleted; normal retry will not restore it. To explicitly create a new task (preserving any existing Wiki body), use: pages task retry '+payload['request_id']+' --recreate-deleted',e.status,e.payload) from e
|
||||
if e.status==409 and e.payload.get('error')=='capture_missing':
|
||||
raise Failure('Draft retained. The server has a capture receipt but no task or deletion record. Server-side consistency repair is required; retry will not fix it.',e.status,e.payload) from e
|
||||
if e.status==412:
|
||||
raise Failure('Draft retained. This request ID conflicts with a server capture or task. An unchanged retry will not resolve it; inspect with: pages task show '+payload['request_id'],e.status,e.payload) from e
|
||||
if e.status==409 and e.payload.get('error')=='note_exists':
|
||||
raise Failure('Draft retained. A Wiki page already occupies the destination; it was not overwritten.',e.status,e.payload) from e
|
||||
print('Draft retained; retry with: pages task retry '+payload['request_id'],file=sys.stderr)
|
||||
if e.payload.get('error') == 'wiki_prefix_required': raise Failure('Set a private Wiki destination first: pages task preferences --wiki-prefix /YOUR/MAIL/PATH',e.status) from e
|
||||
raise
|
||||
@@ -607,6 +615,19 @@ def tasks(client, profile, words):
|
||||
if action=='retry':
|
||||
payload=profile.data.get('task_outbox',{}).get(a.request_id)
|
||||
if not payload:raise Failure('No retained task capture with this request ID.')
|
||||
if a.recreate_deleted:
|
||||
pending=profile.data['task_outbox']
|
||||
replacement=str(uuid.uuid5(uuid.NAMESPACE_URL,'pages:task-recreate:'+a.request_id))
|
||||
payload=dict(payload,request_id=replacement,replaces_deleted=a.request_id)
|
||||
if replacement in pending and pending[replacement]!=payload:
|
||||
raise Failure('A different recreation draft already exists; inspect or retry it first: '+replacement)
|
||||
previous=pending.copy()
|
||||
pending[replacement]=payload;del pending[a.request_id]
|
||||
try:profile.save()
|
||||
except Exception:
|
||||
profile.data['task_outbox']=previous
|
||||
raise
|
||||
print('Recreation draft saved. Existing Wiki content will be preserved. Retry ID: '+replacement,file=sys.stderr)
|
||||
emit(capture(payload));return
|
||||
if action in ('add','from-mail'):
|
||||
payload={'request_id':getattr(a,'request_id',None) or str(uuid.uuid4()),'title':a.title,'notes':a.notes or ''}
|
||||
|
||||
Reference in new issue
Block a user