Skip to content

Commit

Permalink
fix: gzip files to xtransit prefix (#57)
Browse files Browse the repository at this point in the history
* fix: gzip files to xtransit prefix
  • Loading branch information
killagu authored Sep 22, 2024
1 parent 9c014ea commit 5eb1958
Show file tree
Hide file tree
Showing 2 changed files with 12 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
14 changes: 11 additions & 3 deletions common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,25 @@ exports.getNodeProcessInfo = function(proc, platform) {

exports.sleep = promisify(setTimeout);

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

exports.getXprofilePrefix = 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.getXprofilePrefix();
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 5eb1958

Please sign in to comment.