Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gzip files to xtransit prefix #57

Merged
merged 3 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
};
Loading