Skip to content

Commit

Permalink
fix: gzip files to xtransit prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
killagu committed Sep 22, 2024
1 parent 9c014ea commit 76f661b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion commands/upload_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ console.warn = function() { };
async function gzipFile(filePath) {
// 避免文件同名,对原路径取 md5 哈希作为新文件名
const pathHash = crypto.createHash('md5').update(filePath).digest('hex');
const gzippedFile = path.join(utils.getXtransitPath(), `${path.basename(filePath)}-${pathHash}.gz`);
const gzippedFile = path.join(utils.getXtransitPrefix(), `${path.basename(filePath)}-${pathHash}.gz`);
if (await exists(gzippedFile)) {
return gzippedFile;
}
Expand Down
10 changes: 7 additions & 3 deletions common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,21 @@ exports.getNodeProcessInfo = function(proc, platform) {

exports.sleep = promisify(setTimeout);

exports.getXtransitPrefix = function() {
return process.env.XPROFILER_PREFIX || process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR || os.homedir();
};

exports.getXprofilerPath = function() {
const prefix = process.env.XPROFILER_PREFIX || process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR || os.homedir();
const prefix = exports.getXtransitPrefix();
return path.join(prefix, '.xprofiler');
};

exports.getXtransitPath = function() {
const prefix = process.env.XTRANSIT_PREFIX || process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR || os.homedir();
const prefix = exports.getXtransitPrefix();
return path.join(prefix, '.xtransit');
};

exports.getXtransitLogPath = function() {
const prefix = process.env.XTRANSIT_PREFIX || process.env.XPROFILER_UNIT_TEST_TMP_HOMEDIR || os.homedir();
const prefix = exports.getXtransitPrefix();
return path.join(prefix, '.xtransit.log');
};

0 comments on commit 76f661b

Please sign in to comment.