@@ -820,8 +820,23 @@ const exportCustomDomainsTable = async accountId => {
820820 return formatTableRowsToString ( Table . CUSTOM_DOMAIN , customDomainsRows ) ;
821821} ;
822822
823- const exportEncryptDatabaseToFile = async ( { outputPath, accountObj } ) => {
823+ const handleProgressCallback = ( progress , message , email , progressCallback ) => {
824+ if ( ! progressCallback ) return ;
825+ progressCallback ( {
826+ progress : parseInt ( progress ) ,
827+ message,
828+ email
829+ } ) ;
830+ } ;
831+
832+ const exportEncryptDatabaseToFile = async ( {
833+ outputPath,
834+ accountObj,
835+ progressCallback
836+ } ) => {
824837 const filepath = outputPath ;
838+ const PROGRESS_TOTAL_STEPS = 19 ;
839+ let exportProgress = 0 ;
825840
826841 const [ recipientId , domain ] = accountObj
827842 ? accountObj . recipientId . split ( '@' )
@@ -832,31 +847,184 @@ const exportEncryptDatabaseToFile = async ({ outputPath, accountObj }) => {
832847 recipientId : recipientId ,
833848 domain : domain || APP_DOMAIN
834849 } ) ;
850+
851+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
852+ handleProgressCallback (
853+ exportProgress ,
854+ 'saving_account' ,
855+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
856+ progressCallback
857+ ) ;
858+
835859 await saveToFile ( { data : fileInformation , filepath, mode : 'w' } , true ) ;
836860
861+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
862+ handleProgressCallback (
863+ exportProgress ,
864+ 'exporting_contacts' ,
865+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
866+ progressCallback
867+ ) ;
868+
837869 const contacts = await exportContactTable ( accountId ) ;
870+
871+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
872+ handleProgressCallback (
873+ exportProgress ,
874+ 'saving_contacts' ,
875+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
876+ progressCallback
877+ ) ;
878+
838879 await saveToFile ( { data : contacts , filepath, mode : 'a' } ) ;
839880
881+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
882+ handleProgressCallback (
883+ exportProgress ,
884+ 'exporting_labels' ,
885+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
886+ progressCallback
887+ ) ;
888+
840889 const labels = await exportLabelTable ( accountId ) ;
890+
891+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
892+ handleProgressCallback (
893+ exportProgress ,
894+ 'saving_labels' ,
895+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
896+ progressCallback
897+ ) ;
898+
841899 await saveToFile ( { data : labels , filepath, mode : 'a' } ) ;
842900
901+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
902+ handleProgressCallback (
903+ exportProgress ,
904+ 'exporting_emails' ,
905+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
906+ progressCallback
907+ ) ;
908+
843909 const emails = await exportEmailTable ( accountId ) ;
910+
911+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
912+ handleProgressCallback (
913+ exportProgress ,
914+ 'saving_emails' ,
915+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
916+ progressCallback
917+ ) ;
918+
844919 await saveToFile ( { data : emails , filepath, mode : 'a' } ) ;
845920
921+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
922+ handleProgressCallback (
923+ exportProgress ,
924+ 'exporting_email_contacts' ,
925+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
926+ progressCallback
927+ ) ;
928+
846929 const emailContacts = await exportEmailContactTable ( accountId ) ;
930+
931+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
932+ handleProgressCallback (
933+ exportProgress ,
934+ 'saving_email_contacts' ,
935+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
936+ progressCallback
937+ ) ;
938+
847939 await saveToFile ( { data : emailContacts , filepath, mode : 'a' } ) ;
848940
941+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
942+ handleProgressCallback (
943+ exportProgress ,
944+ 'exporting_email_labels' ,
945+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
946+ progressCallback
947+ ) ;
948+
849949 const emailLabels = await exportEmailLabelTable ( accountId ) ;
950+
951+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
952+ handleProgressCallback (
953+ exportProgress ,
954+ 'saving_email_labels' ,
955+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
956+ progressCallback
957+ ) ;
958+
850959 await saveToFile ( { data : emailLabels , filepath, mode : 'a' } ) ;
851960
961+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
962+ handleProgressCallback (
963+ exportProgress ,
964+ 'exporting_files' ,
965+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
966+ progressCallback
967+ ) ;
968+
852969 const files = await exportFileTable ( accountId ) ;
970+
971+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
972+ handleProgressCallback (
973+ exportProgress ,
974+ 'saving_files' ,
975+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
976+ progressCallback
977+ ) ;
978+
853979 await saveToFile ( { data : files , filepath, mode : 'a' } ) ;
854980
981+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
982+ handleProgressCallback (
983+ exportProgress ,
984+ 'exporting_aliases' ,
985+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
986+ progressCallback
987+ ) ;
988+
855989 const aliases = await exportAliasTable ( accountId ) ;
990+
991+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
992+ handleProgressCallback (
993+ exportProgress ,
994+ 'saving_aliases' ,
995+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
996+ progressCallback
997+ ) ;
998+
856999 await saveToFile ( { data : aliases , filepath, mode : 'a' } ) ;
8571000
1001+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
1002+ handleProgressCallback (
1003+ exportProgress ,
1004+ 'exporting_domains' ,
1005+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
1006+ progressCallback
1007+ ) ;
1008+
8581009 const customDomains = await exportCustomDomainsTable ( accountId ) ;
1010+
1011+ exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
1012+ handleProgressCallback (
1013+ exportProgress ,
1014+ 'saving_domains' ,
1015+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
1016+ progressCallback
1017+ ) ;
1018+
8591019 await saveToFile ( { data : customDomains , filepath, mode : 'a' } ) ;
1020+
1021+ exportProgress = 99 ;
1022+ handleProgressCallback (
1023+ exportProgress ,
1024+ 'almost_done' ,
1025+ `${ recipientId } @${ domain || APP_DOMAIN } ` ,
1026+ progressCallback
1027+ ) ;
8601028} ;
8611029
8621030const importDatabaseFromFile = async ( {
0 commit comments