@@ -99,25 +99,27 @@ async function showMetadata(fileUri: vscode.Uri, viewColumn: vscode.ViewColumn)
9999class MetadataProvider implements vscode . TextDocumentContentProvider {
100100 private exifTool : any = null ;
101101 private useNativeExifTool : boolean = false ;
102- private initializationAttempted : boolean = false ;
102+ private initializationPromise : Promise < void > | null = null ;
103103 private initializationError : string | null = null ;
104104
105105 constructor ( ) {
106- this . initializeExifTool ( ) ;
106+ // Start initialization but don't wait for it
107+ this . initializationPromise = this . initializeExifTool ( ) ;
107108 }
108109
109110 private async initializeExifTool ( ) {
110- if ( this . initializationAttempted ) {
111+ if ( this . exifTool || this . useNativeExifTool ) {
112+ // Already initialized successfully
111113 return ;
112114 }
113- this . initializationAttempted = true ;
114115
115116 outputChannel . appendLine ( 'Attempting to initialize ExifTool...' ) ;
116117
117118 try {
118119 // Try to initialize with exiftool-vendored first
119120 const ExifTool = await loadExifToolClass ( ) ;
120121 this . exifTool = new ExifTool ( ) ;
122+ this . initializationError = null ; // Clear any previous errors
121123 outputChannel . appendLine ( 'ExifTool (vendored) initialized successfully' ) ;
122124 return ;
123125 } catch ( error ) {
@@ -129,6 +131,7 @@ class MetadataProvider implements vscode.TextDocumentContentProvider {
129131 try {
130132 await execAsync ( 'exiftool -ver' ) ;
131133 this . useNativeExifTool = true ;
134+ this . initializationError = null ; // Clear any previous errors
132135 outputChannel . appendLine ( 'Native ExifTool found and will be used as fallback' ) ;
133136 return ;
134137 } catch ( nativeError ) {
@@ -163,9 +166,9 @@ class MetadataProvider implements vscode.TextDocumentContentProvider {
163166 const fileUri = vscode . Uri . file ( uri . path . replace ( '.metadata' , '' ) ) ;
164167 const fileName = fileUri . fsPath . split ( '\\' ) . pop ( ) || fileUri . fsPath . split ( '/' ) . pop ( ) || 'Unknown' ;
165168
166- // Wait for initialization to complete if it's still ongoing
167- if ( ! this . initializationAttempted ) {
168- await this . initializeExifTool ( ) ;
169+ // Wait for initialization to complete
170+ if ( this . initializationPromise ) {
171+ await this . initializationPromise ;
169172 }
170173
171174 const platformInfo = `Platform: ${ os . platform ( ) } ${ os . arch ( ) } \nNode.js: ${ process . version } \nVS Code: ${ vscode . version } ` ;
0 commit comments