@@ -707,6 +707,7 @@ export const useProjectStore = defineStore('projectModule', {
707707 } ,
708708
709709 async downloadArchive ( payload : DownloadPayload ) {
710+ console . log ( "You are here" )
710711 const notificationStore = useNotificationStore ( )
711712 await this . cancelDownloadArchive ( )
712713 this . projectDownloadingVersion = payload . versionId
@@ -719,8 +720,12 @@ export const useProjectStore = defineStore('projectModule', {
719720
720721 const delays = [ ...Array ( 3 ) . fill ( 1000 ) , ...Array ( 3 ) . fill ( 3000 ) , 5000 ]
721722 let retryCount = 0
722- const pollDownloadArchive = async ( ) => {
723- try {
723+ try {
724+ // STEP 1: request archive creation
725+ await ProjectApi . prepareArchive ( payload . url )
726+
727+ // STEP 2: start polling HEAD for readiness
728+ const pollDownloadArchive = async ( ) => {
724729 if ( retryCount > 125 ) {
725730 notificationStore . warn ( {
726731 text : exceedMessage ,
@@ -729,38 +734,42 @@ export const useProjectStore = defineStore('projectModule', {
729734 await this . cancelDownloadArchive ( )
730735 return
731736 }
732-
733- const head = await ProjectApi . getHeadDownloadFile ( payload . url )
734- const polling = head . status == 202
735- if ( polling ) {
736- const delay = delays [ Math . min ( retryCount , delays . length - 1 ) ] // Select delay based on retry count
737- retryCount ++ // Increment retry count
738- downloadArchiveTimeout = setTimeout ( async ( ) => {
739- await pollDownloadArchive ( )
740- } , delay )
741- return
742- }
743-
744- // Use browser download instead of playing around with the blob
745- FileSaver . saveAs ( payload . url )
746- notificationStore . closeNotification ( )
747- this . cancelDownloadArchive ( )
748- } catch ( e ) {
749- if ( axios . isAxiosError ( e ) && e . response ?. status === 400 ) {
750- notificationStore . error ( {
751- group : 'download-large-error' ,
752- text : '' ,
753- life : 6000
754- } )
755- } else {
756- notificationStore . error ( {
757- text : errorMessage
758- } )
737+ try {
738+ const head = await ProjectApi . getHeadDownloadFile ( payload . url )
739+ const polling = head . status === 202
740+ if ( polling ) {
741+ const delay = delays [ Math . min ( retryCount , delays . length - 1 ) ] // Select delay based on retry count
742+ retryCount ++ // Increment retry count
743+ downloadArchiveTimeout = setTimeout ( async ( ) => {
744+ await pollDownloadArchive ( )
745+ } , delay )
746+ return
747+ }
748+
749+ // Use browser download instead of playing around with the blob
750+ FileSaver . saveAs ( payload . url )
751+ notificationStore . closeNotification ( )
752+ this . cancelDownloadArchive ( )
753+ } catch ( e ) {
754+ if ( axios . isAxiosError ( e ) && e . response ?. status === 400 ) {
755+ notificationStore . error ( {
756+ group : 'download-large-error' ,
757+ text : '' ,
758+ life : 6000
759+ } )
760+ } else {
761+ notificationStore . error ( {
762+ text : errorMessage
763+ } )
764+ }
765+ this . cancelDownloadArchive ( )
759766 }
760- this . cancelDownloadArchive ( )
761767 }
768+ pollDownloadArchive ( )
769+ } catch ( e ) {
770+ notificationStore . error ( { text : errorMessage } )
771+ this . cancelDownloadArchive ( )
762772 }
763- pollDownloadArchive ( )
764773 } ,
765774
766775 async cancelDownloadArchive ( ) {
0 commit comments