@@ -1645,7 +1645,7 @@ export async function backupSize (storage: BackupStorage): Promise<void> {
16451645/**
16461646 * @public
16471647 */
1648- export async function backupDownload ( storage : BackupStorage , storeIn : string ) : Promise < void > {
1648+ export async function backupDownload ( storage : BackupStorage , storeIn : string , skipDomains : Set < string > ) : Promise < void > {
16491649 const infoFile = 'backup.json.gz'
16501650 const sizeFile = 'backup.size.gz'
16511651
@@ -1655,15 +1655,16 @@ export async function backupDownload (storage: BackupStorage, storeIn: string):
16551655 let size = 0
16561656
16571657 const backupInfo : BackupInfo = JSON . parse ( gunzipSync ( new Uint8Array ( await storage . loadFile ( infoFile ) ) ) . toString ( ) )
1658- console . log ( 'workspace:' , backupInfo . workspace ?? '' , backupInfo . version )
1658+ console . log ( 'Downloading workspace:' , backupInfo . workspace ?? '' , backupInfo . version , backupInfo . snapshots . length )
16591659
16601660 let sizeInfo : Record < string , number > = { }
16611661 if ( await storage . exists ( sizeFile ) ) {
1662+ console . log ( 'Parse size file' )
16621663 sizeInfo = JSON . parse ( gunzipSync ( new Uint8Array ( await storage . loadFile ( sizeFile ) ) ) . toString ( ) )
16631664 }
1664- console . log ( 'workspace:' , backupInfo . workspace ?? '' , backupInfo . version )
16651665
1666- const addFileSize = async ( file : string | undefined | null , force : boolean = false ) : Promise < void > => {
1666+ const downloadFile = async ( file : string | undefined | null , force : boolean = false ) : Promise < void > => {
1667+ console . log ( 'Download file' , file )
16671668 if ( file != null ) {
16681669 const target = join ( storeIn , file )
16691670 const dir = dirname ( target )
@@ -1700,17 +1701,21 @@ export async function backupDownload (storage: BackupStorage, storeIn: string):
17001701
17011702 // Let's calculate data size for backup
17021703 for ( const sn of backupInfo . snapshots ) {
1703- for ( const [ , d ] of Object . entries ( sn . domains ) ) {
1704- await addFileSize ( d . snapshot )
1704+ console . log ( 'processing' , sn . date )
1705+ for ( const [ k , d ] of Object . entries ( sn . domains ) ) {
1706+ if ( skipDomains . has ( k ) ) {
1707+ continue
1708+ }
1709+ await downloadFile ( d . snapshot )
17051710 for ( const snp of d . snapshots ?? [ ] ) {
1706- await addFileSize ( snp )
1711+ await downloadFile ( snp )
17071712 }
17081713 for ( const snp of d . storage ?? [ ] ) {
1709- await addFileSize ( snp )
1714+ await downloadFile ( snp )
17101715 }
17111716 }
17121717 }
1713- await addFileSize ( infoFile , true )
1718+ await downloadFile ( infoFile , true )
17141719
17151720 console . log ( 'Backup size' , size / ( 1024 * 1024 ) , 'Mb' )
17161721}
0 commit comments