@ -9,7 +9,9 @@ C:\Dev\.keys\offband-log-key (with the owner's other keys; OFFBAND_LOG_KEY
overrides the path ) and into Bitwarden ; without it no upload can ever be read .
The public key goes into the app .
list shows uploads not pulled yet . pull downloads an upload , decrypts it and
list shows uploads not pulled yet . It also flags , and exits 1 for , any of them
that already has a folder in debug_logs : decrypted without the seen step , so
it would never be deleted ( #1318). pull downloads an upload, decrypts it and
unpacks it into the main checkout ' s debug_logs, in a folder named
" YYYY-MM-DD OB-XXXXX <sender ' s name> " ( OFFBAND_LOG_DIR overrides the parent
folder ) . It is never written inside a worktree , which would lose it when the
@ -60,6 +62,7 @@ MAX_SENDER_BYTES = 4096
MAX_UNPACKED_BYTES = 1024 * 1024 * 1024
UNSAFE_IN_NAME = re . compile ( r ' [<>: " / \\ |?* \ x00- \ x1f] ' )
CODE = re . compile ( r " ^OB-[23456789ABCDEFGHJKMNPQRSTUVWXYZ] {5} $ " )
CODE_IN_TITLE = re . compile ( r " OB-[23456789ABCDEFGHJKMNPQRSTUVWXYZ] {5} (?=:) " )
OBJECT = re . compile ( r " `(uploads/(OB-[23456789ABCDEFGHJKMNPQRSTUVWXYZ] {5} )-[0-9a-f-] {36} \ .bin)` " )
@ -257,6 +260,37 @@ def unseen(issues: list) -> list:
return [ i for i in issues if SEEN_LABEL not in { label [ " name " ] for label in i [ " labels " ] } ]
def local_folders ( code : str , out_root : Path ) - > list :
""" Folders pull has made for this code: " OB-XXXXX " (before #1217 ' s naming),
" YYYY-MM-DD OB-XXXXX[ name] " , or either with free_dir ' s " -N " suffix. " " "
if not out_root . is_dir ( ) :
return [ ]
pattern = re . compile ( rf " ^( \ d {{ 4 }} - \ d {{ 2 }} - \ d {{ 2 }} )? { re . escape ( code ) } (- \ d+)?( |$) " )
return sorted ( p . name for p in out_root . iterdir ( ) if p . is_dir ( ) and pattern . match ( p . name ) )
def list_uploads ( issues : list , out_root : Path , out = None ) - > int :
""" Print the uploads not marked seen. Flag any that already has a folder
here : it was decrypted without the seen step , so retention never starts
( #1318). Returns how many were flagged."""
out = out or sys . stdout
waiting = unseen ( issues )
flagged = 0
for issue in waiting :
line = f " # { issue [ ' number ' ] } { issue [ ' createdAt ' ] [ : 16 ] } { issue [ ' title ' ] } "
code = CODE_IN_TITLE . match ( issue [ " title " ] )
folders = local_folders ( code . group ( 0 ) , out_root ) if code else [ ]
if folders :
flagged + = 1
line + = f " \n decrypted here but not marked seen: { ' , ' . join ( folders ) } "
print ( line , file = out )
print ( f " { len ( waiting ) } upload(s) not pulled yet. " , file = out )
if flagged :
print ( f " { flagged } of them were decrypted without being marked seen, so they will never "
f " be deleted. Pull each again to mark it, or see #1318. " , file = out )
return flagged
def pull ( code : str , * , key = None , issues = None , fetch = download , seen = mark_seen ,
out_root : Path = None , out = sys . stdout ) - > list :
if not CODE . match ( code ) :
@ -303,10 +337,8 @@ def main(argv=None) -> int:
if args . command == " keygen " :
keygen ( )
elif args . command == " list " :
waiting = unseen ( intake_issues ( " open " ) )
for issue in waiting :
print ( f " # { issue [ ' number ' ] } { issue [ ' createdAt ' ] [ : 16 ] } { issue [ ' title ' ] } " )
print ( f " { len ( waiting ) } upload(s) not pulled yet. " )
if list_uploads ( intake_issues ( " open " ) , default_out_root ( ) ) :
return 1
else :
pull ( args . code )
return 0