Skip to content
This repository has been archived by the owner on May 22, 2020. It is now read-only.

Commit

Permalink
RUN-3981 override user_data & cache directory for MAC (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoOpenfin authored and HarsimranSingh committed May 18, 2018
1 parent 031b2a3 commit e38be77
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ portDiscovery.on('runtime/launched', (portInfo) => {

includeFlashPlugin();

// Enable Single tenant for MAC
handleMacSingleTenant();

// Opt in to launch crash reporter
initializeCrashReporter(coreState.argo);

Expand Down Expand Up @@ -712,6 +715,19 @@ function registerMacMenu() {
}
}

// Set usrData & userCache path specifically for each application for MAC_OS
function handleMacSingleTenant() {
if (process.platform === 'darwin') {
const configUrl = coreState.argo['startup-url'] || coreState.argo['config'];
let pathPost = encodeURIComponent(configUrl);
if (coreState.argo['security-realm']) {
pathPost = pathPost.concat(coreState.argo['security-realm']);
}
app.setPath('userData', path.join(USER_DATA, pathPost));
app.setPath('userCache', path.join(USER_DATA, pathPost));
}
}

function needsCrashReporter(argo) {
return !!(argo['diagnostics'] || argo['enable-crash-reporting']);
}
Expand Down
3 changes: 2 additions & 1 deletion src/browser/api/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import {
const subscriptionManager = new SubscriptionManager();
const isWin32 = process.platform === 'win32';
const windowPosCacheFolder = 'winposCache';
const userCache = electronApp.getPath('userCache');
const WindowsMessages = {
WM_KEYDOWN: 0x0100,
WM_KEYUP: 0x0101,
Expand Down Expand Up @@ -1942,6 +1941,7 @@ function saveBoundsToDisk(identity, bounds, callback) {
};

try {
const userCache = electronApp.getPath('userCache');
fs.mkdir(path.join(userCache, windowPosCacheFolder), () => {
fs.writeFile(cacheFile, JSON.stringify(data), (writeFileErr) => {
callback(writeFileErr);
Expand All @@ -1955,6 +1955,7 @@ function saveBoundsToDisk(identity, bounds, callback) {
//make sure the uuid/names with special characters do not break the bounds cache.
function getBoundsCacheSafeFileName(identity) {
let safeName = new Buffer(identity.uuid + '-' + identity.name).toString('hex');
const userCache = electronApp.getPath('userCache');
return path.join(userCache, windowPosCacheFolder, `${safeName}.json`);
}

Expand Down

0 comments on commit e38be77

Please sign in to comment.