@@ -11,14 +11,12 @@ import * as CodeWhispererConstants from '../../models/constants'
1111import { JDKVersion , TransformationType , transformByQState } from '../../models/model'
1212import { getLogger } from '../../../shared/logger/logger'
1313import { codeWhispererClient } from '../../../codewhisperer/client/codewhisperer'
14- import { pollTransformationStatusUntilComplete } from '../../commands/startTransformByQ'
15- import { downloadAndExtractResultArchive } from './transformApiHandler'
14+ import { downloadAndExtractResultArchive , pollTransformationJob } from './transformApiHandler'
1615import { ChatSessionManager } from '../../../amazonqGumby/chat/storages/chatSession'
1716import { AuthUtil } from '../../util/authUtil'
1817import { setMaven } from './transformFileHandler'
1918import { convertToTimeString , isWithin30Days } from '../../../shared/datetime'
20- import { ExportResultArchiveStructure } from '../../../shared/utilities/download'
21- import { isFileNotFoundError } from '../../../shared/errors'
19+ import { copyArtifacts } from './transformFileHandler'
2220
2321export interface HistoryObject {
2422 startTime : string
@@ -111,43 +109,6 @@ export async function createMetadataFile(payloadFilePath: string, metadata: JobM
111109 return jobHistoryPath
112110}
113111
114- /**
115- * Saves a copy of the diff patch, summary, and build logs (if any) locally
116- *
117- * @param pathToArchiveDir path to the archive directory where the artifacts are unzipped
118- * @param pathToDestinationDir destination directory (will create directories if path doesn't exist already)
119- */
120- export async function copyArtifacts ( pathToArchiveDir : string , pathToDestinationDir : string ) {
121- // create destination path if doesn't exist already
122- // mkdir() will not raise an error if path exists
123- await fs . mkdir ( pathToDestinationDir )
124-
125- const diffPath = path . join ( pathToArchiveDir , ExportResultArchiveStructure . PathToDiffPatch )
126- const summaryPath = path . join ( pathToArchiveDir , ExportResultArchiveStructure . PathToSummary )
127-
128- try {
129- await fs . copy ( diffPath , path . join ( pathToDestinationDir , 'diff.patch' ) )
130- // make summary directory if needed
131- await fs . mkdir ( path . join ( pathToDestinationDir , 'summary' ) )
132- await fs . copy ( summaryPath , path . join ( pathToDestinationDir , 'summary' , 'summary.md' ) )
133- } catch ( error ) {
134- getLogger ( ) . error ( 'Code Transformation: Error saving local copy of artifacts: %s' , ( error as Error ) . message )
135- }
136-
137- const buildLogsPath = path . join ( summaryPath , 'buildCommandOutput.log' )
138- try {
139- await fs . copy ( buildLogsPath , path . join ( pathToDestinationDir , 'summary' , 'buildCommandOutput.log' ) )
140- } catch ( error ) {
141- // build logs won't exist for SQL conversions (not an error)
142- if ( ! isFileNotFoundError ( error ) ) {
143- getLogger ( ) . error (
144- 'Code Transformation: Error saving local copy of build logs: %s' ,
145- ( error as Error ) . message
146- )
147- }
148- }
149- }
150-
151112/**
152113 * Writes job details to history file
153114 *
@@ -248,7 +209,7 @@ export async function refreshJob(jobId: string, currentStatus: string, projectNa
248209 getLogger ( ) . error ( 'Code Transformation: Error fetching status (job id: %s): %s' , jobId , errorMessage )
249210 if ( errorMessage . includes ( 'not authorized to make this call' ) ) {
250211 // job not available on backend
251- status = 'FAILED'
212+ status = 'FAILED' // won't allow retries for this job
252213 } else {
253214 // some other error (e.g. network error)
254215 return
@@ -418,8 +379,9 @@ async function setupTransformationState(jobId: string, projectName: string, stat
418379}
419380
420381async function pollAndCompleteTransformation ( jobId : string ) {
421- const status = await pollTransformationStatusUntilComplete (
382+ const status = await pollTransformationJob (
422383 jobId ,
384+ CodeWhispererConstants . validStatesForCheckingDownloadUrl ,
423385 AuthUtil . instance . regionProfileManager . activeRegionProfile
424386 )
425387 await cleanupTempJobFiles ( transformByQState . getJobHistoryPath ( ) , status , transformByQState . getPayloadFilePath ( ) )
0 commit comments