Skip to content

Commit

Permalink
fix: remove unused param from uploadSymbolFiles
Browse files Browse the repository at this point in the history
Fixes #108

BREAKING CHANGE: changes signature of public function uploadSymbolFiles
  • Loading branch information
bobbyg603 committed Apr 17, 2024
1 parent 422234c commit b9b224e
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ import { CommandLineDefinition, argDefinitions, usageDefinitions } from './comma
}
}

await uploadSymbolFiles(bugsplat, database, application, version, directory, symbolFilePaths);
await uploadSymbolFiles(bugsplat, database, application, version, symbolFilePaths);
await safeRemoveTmp();
process.exit(0);
})().catch(async (error) => {
Expand Down
4 changes: 1 addition & 3 deletions spec/dsym.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ describe('dsym', () => {
return expectAsync(getDSymFileInfos('spec/support/bugsplat.pdb')).toBeResolvedTo(jasmine.arrayContaining([]));
});

it('should return path, relativePath, dbgIds, module names for macho files', () => {
it('should return path, dbgIds, module names for macho files', () => {
return expectAsync(getDSymFileInfos('spec/support/bugsplat.app.dSYM')).toBeResolvedTo(jasmine.arrayContaining([
{
path: jasmine.stringMatching(/tmp[\/\\]2dd1bd2706fa384da5a3a8265921cf9a[\/\\]BugsplatTester/),
relativePath: jasmine.stringMatching(/2dd1bd2706fa384da5a3a8265921cf9a[\/\\]BugsplatTester/),
dbgId: '2dd1bd2706fa384da5a3a8265921cf9a',
moduleName: 'BugsplatTester',
},
{
path: jasmine.stringMatching(/tmp[\/\\]2ce192f6c5963e66b06aa22bde5756a0[\/\\]BugsplatTester/),
relativePath: jasmine.stringMatching(/2ce192f6c5963e66b06aa22bde5756a0[\/\\]BugsplatTester/),
dbgId: '2ce192f6c5963e66b06aa22bde5756a0',
moduleName: 'BugsplatTester',
}
Expand Down
2 changes: 0 additions & 2 deletions spec/worker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ function createFakeSymbolFileInfos(count: number) {
return Array.from(Array(count).keys())
.map((i) => createFakeSymbolFileInfo({
path: `path${i}`,
relativePath: `relativePath${i}`,
moduleName: `moduleName${i}`,
dbgId: `dbgId${i}`
})
Expand All @@ -163,7 +162,6 @@ function createFakeSymbolFileInfo(params: Partial<SymbolFileInfo>): SymbolFileIn
path: 'path',
moduleName: 'moduleName',
dbgId: 'dbgId',
relativePath: 'relativePath',
};
return {
...defaults,
Expand Down
1 change: 0 additions & 1 deletion src/dsym.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export async function getDSymFileInfos(path: string): Promise<SymbolFileInfo[]>
await macho.writeFile(path);
return {
path,
relativePath,
dbgId,
moduleName,
}
Expand Down
1 change: 0 additions & 1 deletion src/info.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export type SymbolFileInfo = {
path: string;
relativePath: string;
moduleName: string;
dbgId: string;
}
15 changes: 4 additions & 11 deletions src/upload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiClient, SymbolsApiClient, VersionsApiClient } from "@bugsplat/js-api-client";
import { basename, dirname, extname, join, relative } from "node:path";
import { basename, extname, join } from "node:path";
import { pool } from "workerpool";
import { getDSymFileInfos } from './dsym';
import { tryGetElfUUID } from './elf';
Expand All @@ -10,14 +10,13 @@ import { createWorkersFromSymbolFiles } from './worker';

const workerPool = pool(join(__dirname, 'compression.js'));

// TODO BG should symbolFilePaths be relative to directory?
export async function uploadSymbolFiles(bugsplat: ApiClient, database: string, application: string, version: string, directory: string, symbolFilePaths: Array<string>) {
export async function uploadSymbolFiles(bugsplat: ApiClient, database: string, application: string, version: string, symbolFilePaths: Array<string>) {
console.log(`About to upload symbols for ${database}-${application}-${version}...`);

const symbolsApiClient = new SymbolsApiClient(bugsplat);
const versionsApiClient = new VersionsApiClient(bugsplat);
const symbolFiles = await Promise.all(
symbolFilePaths.map(async (symbolFilePath) => await createSymbolFileInfos(directory, symbolFilePath))
symbolFilePaths.map(async (symbolFilePath) => await createSymbolFileInfos(symbolFilePath))
).then(array => array.flat());
const workers = createWorkersFromSymbolFiles(workerPool, symbolFiles, [symbolsApiClient, versionsApiClient]);
const uploads = workers.map((worker) => worker.upload(database, application, version));
Expand All @@ -26,9 +25,8 @@ export async function uploadSymbolFiles(bugsplat: ApiClient, database: string, a
console.log('Symbols uploaded successfully!');
}

async function createSymbolFileInfos(searchDirectory: string, symbolFilePath: string): Promise<SymbolFileInfo[]> {
async function createSymbolFileInfos(symbolFilePath: string): Promise<SymbolFileInfo[]> {
const path = symbolFilePath;
const relativePath = relative(searchDirectory, dirname(path));
const extLowerCase = extname(path).toLowerCase();
const isSymFile = extLowerCase.includes('.sym');
const isPdbFile = extLowerCase.includes('.pdb');
Expand All @@ -43,7 +41,6 @@ async function createSymbolFileInfos(searchDirectory: string, symbolFilePath: st
path,
dbgId,
moduleName,
relativePath
} as SymbolFileInfo];
}

Expand All @@ -54,7 +51,6 @@ async function createSymbolFileInfos(searchDirectory: string, symbolFilePath: st
path,
dbgId,
moduleName,
relativePath
} as SymbolFileInfo];
}

Expand All @@ -64,7 +60,6 @@ async function createSymbolFileInfos(searchDirectory: string, symbolFilePath: st
path,
dbgId,
moduleName,
relativePath
} as SymbolFileInfo];
}

Expand All @@ -79,7 +74,6 @@ async function createSymbolFileInfos(searchDirectory: string, symbolFilePath: st
path,
dbgId,
moduleName,
relativePath
} as SymbolFileInfo];
}

Expand All @@ -89,6 +83,5 @@ async function createSymbolFileInfos(searchDirectory: string, symbolFilePath: st
path,
dbgId,
moduleName,
relativePath
} as SymbolFileInfo];
}
5 changes: 2 additions & 3 deletions src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ export class UploadWorker {
}

private async uploadSingle(database: string, application: string, version: string, symbolFileInfo: SymbolFileInfo): Promise<void> {
let { path, relativePath } = symbolFileInfo;
const { dbgId, moduleName } = symbolFileInfo;
const folderPrefix = relativePath.replace(/\\/g, '-').replace(/\//g, '-');
const { dbgId, moduleName, path } = symbolFileInfo;
const folderPrefix = dirname(path).replace(/\\/g, '-').replace(/\//g, '-');
const fileName = folderPrefix ? [folderPrefix, basename(path)].join('-') : basename(path);
const uncompressedSize = await this.stat(path).then(stats => stats.size);
const timestamp = Math.round(new Date().getTime() / 1000);
Expand Down

0 comments on commit b9b224e

Please sign in to comment.