Skip to content

Commit 993cf6c

Browse files
authored
Add logging around file fetching (#6110)
1 parent 9da0970 commit 993cf6c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/github/githubRepository.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,7 @@ export class GitHubRepository implements vscode.Disposable {
10761076
const { octokit, remote } = await this.ensure();
10771077
let contents: string = '';
10781078
let fileContent: { data: { content: string; encoding: string; sha: string } };
1079+
Logger.debug(`Fetch file ${filePath} - enter`, this.id);
10791080
try {
10801081
fileContent = (await octokit.call(octokit.api.repos.getContent,
10811082
{
@@ -1092,6 +1093,7 @@ export class GitHubRepository implements vscode.Disposable {
10921093

10931094
contents = fileContent.data.content ?? '';
10941095
} catch (e) {
1096+
Logger.error(`Unable to fetch file ${filePath}: ${e}`, this.id);
10951097
if (e.status === 404) {
10961098
return new Uint8Array(0);
10971099
}
@@ -1100,16 +1102,19 @@ export class GitHubRepository implements vscode.Disposable {
11001102

11011103
// Empty contents and 'none' encoding indcates that the file has been truncated and we should get the blob.
11021104
if (contents === '' && fileContent.data.encoding === 'none') {
1105+
Logger.debug(`Fetch blob file ${filePath} - enter`, this.id);
11031106
const fileSha = fileContent.data.sha;
11041107
fileContent = await octokit.call(octokit.api.git.getBlob, {
11051108
owner: remote.owner,
11061109
repo: remote.repositoryName,
11071110
file_sha: fileSha,
11081111
});
11091112
contents = fileContent.data.content;
1113+
Logger.debug(`Fetch blob file ${filePath} - done`, this.id);
11101114
}
11111115

11121116
const buff = buffer.Buffer.from(contents, (fileContent.data as any).encoding);
1117+
Logger.debug(`Fetch file ${filePath}, file length ${contents.length} - done`, this.id);
11131118
return buff;
11141119
}
11151120

0 commit comments

Comments
 (0)