o k˜`Ï ã@sHddlZddlmZddlmZmZmZddlm Z dd„Z dd„Z dS) éN)Ú Attachment)Úexception_to_unicodeÚprinterrÚ unicode_quote)Ú_c Csrtj |jd¡}tj |¡sdSt |¡}tj |j¡s"t |j¡| d¡|D] }t|g|¢RŽq)t  tj |jd¡¡D];\}}}z-t tdƒrQt  ||j ¡t tdƒrbt |dƒrbt  ||j¡t tdƒrpt ||j|j¡Wq?tyzYq?wztj |d d D] \}}}t |¡qƒWdSty¸} z|j d |t| ƒ¡ttd |t| ƒd ƒWYd} ~ dSd} ~ ww)ziMove attachments from the `attachments` directory into `files`, hashing the filenames in the process.Ú attachmentsNzM SELECT type, id, filename FROM attachment ORDER BY type, id ÚfilesÚchmodÚchflagsÚst_flagsÚchownF)Útopdownz-Can't delete old attachments directory %s: %sauThe upgrade of attachments was successful, but the old attachments directory: %(src_dir)s couldn't be removed, possibly due to the presence of files that weren't referenced in the database. The error was: %(exception)s This error can be ignored, but for keeping your environment clean you should backup any remaining files in that directory and remove it manually. )Úsrc_dirÚ exception)ÚosÚpathÚjoinÚexistsÚstatÚattachments_dirÚmakedirsÚexecuteÚmove_attachment_fileÚwalkÚhasattrr Úst_moder r r Úst_uidÚst_gidÚOSErrorÚrmdirÚlogÚwarningrrr) ÚenvÚversionÚcursorÚold_attachments_dirÚold_statÚrowÚdirÚdirsrÚe©r+ú4/usr/lib/python3/dist-packages/trac/upgrades/db28.pyÚ do_upgradesD       € ÿ ÿÿ ô€ür-c Cs¤tj |jd|t|ƒ¡}|rtj |t|ƒ¡}tj |¡}tj |¡rGt |j|||¡}z t  ||¡WdSt yFt t d||dƒ‚w|j  d|||¡dS)NrzEUnable to move attachment from: %(old_path)s to: %(new_path)s )Úold_pathÚnew_pathz3Can't find file for 'attachment:%s:%s:%s', ignoring)rrrrÚnormpathÚisfilerÚ _get_pathrÚrenamesrrrr r!)r"Ú parent_realmÚ parent_idÚfilenamer.r/r+r+r,rIs*ÿ   ÿ þüÿr) Úos.pathrÚtrac.attachmentrÚtrac.util.textrrrÚtrac.util.translationrr-rr+r+r+r,Ús    4