Skip to content

Commit

Permalink
fix: exFAT error
Browse files Browse the repository at this point in the history
Fixes #148
  • Loading branch information
bobbyg603 committed Jan 2, 2025
1 parent 39b119c commit fda790c
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { BugSplatAuthenticationError, SymbolsApiClient, VersionsApiClient } from '@bugsplat/js-api-client';
import filenamify from 'filenamify';
import { ReadStream, createReadStream, existsSync, mkdirSync } from 'fs';
import { ReadStream, createReadStream } from 'fs';
import { stat } from 'node:fs/promises';
import { basename, dirname, extname, join } from 'node:path';
import { basename, extname, join } from 'node:path';
import prettyBytes from 'pretty-bytes';
import retryPromise from 'promise-retry';
import { WorkerPool } from 'workerpool';
Expand Down Expand Up @@ -50,27 +49,22 @@ export class UploadWorker {

private async uploadSingle(database: string, application: string, version: string, symbolFileInfo: SymbolFileInfo): Promise<UploadStats> {
const { dbgId, moduleName, path } = symbolFileInfo;
const folderPrefix = dirname(path).replace(/\\/g, '-').replace(/\//g, '-');
const fileName = folderPrefix ? [folderPrefix, basename(path)].join('-') : basename(path);
const fileName = basename(path);
const uncompressedSize = await this.stat(path).then(stats => stats.size);
const timestamp = Math.round(new Date().getTime() / 1000);
const uuid = crypto.randomUUID();
const isZip = extname(path).toLowerCase().includes('.zip');

let client: SymbolsApiClient | VersionsApiClient = this.versionsClient;
let name = basename(path);
let tmpFileName = '';

if (dbgId && !isZip) {
const tmpSubdir = join(tmpDir, filenamify(dirname(path)));
if (!existsSync(tmpSubdir)) {
mkdirSync(tmpSubdir, { recursive: true });
}
tmpFileName = join(tmpSubdir, `${fileName}.gz`);
tmpFileName = join(tmpDir, `${fileName}-${dbgId}-${uuid}.gz`);
client = this.symbolsClient;
await this.pool.exec('createGzipFile', [path, tmpFileName]);
} else if (!isZip) {
name = `${name}.zip`;
tmpFileName = join(tmpDir, `${fileName}-${timestamp}.zip`);
tmpFileName = join(tmpDir, `${fileName}-${dbgId}-${uuid}.zip`);
await this.pool.exec('createZipFile', [path, tmpFileName]);
} else {
tmpFileName = path;
Expand Down

0 comments on commit fda790c

Please sign in to comment.