Fix remote and S3 detection
This commit is contained in:
@@ -51,6 +51,12 @@ exports.DATA_LOCATIONS = {
|
||||
win32: '%LOCALAPPDATA%\\repertory\\ui'
|
||||
};
|
||||
|
||||
exports.REPERTORY_LOCATIONS = {
|
||||
linux: '~/.local/repertory',
|
||||
darwin: '~/Library/Application Support/repertory',
|
||||
win32: '%LOCALAPPDATA%\\repertory'
|
||||
};
|
||||
|
||||
exports.S3_PROVIDER_LIST = [
|
||||
'Goobox S3',
|
||||
];
|
||||
@@ -72,6 +78,7 @@ exports.PROVIDER_ARG = {
|
||||
s3: '-s3',
|
||||
};
|
||||
|
||||
exports.DEFAULT_RELEASE = 0;
|
||||
exports.RELEASE_TYPES = [
|
||||
'Release',
|
||||
'RC',
|
||||
|
||||
@@ -213,6 +213,10 @@ const _getDataDirectory = () => {
|
||||
return _resolvePath(Constants.DATA_LOCATIONS[os.platform()]);
|
||||
};
|
||||
|
||||
const _getRepertoryDirectory = () => {
|
||||
return _resolvePath(Constants.REPERTORY_LOCATIONS[os.platform()]);
|
||||
};
|
||||
|
||||
const _getDefaultRepertoryArgs = (provider, remote, s3) => {
|
||||
const providerLower = provider.toLowerCase();
|
||||
const args = [];
|
||||
@@ -728,6 +732,8 @@ module.exports.getConfigTemplate = (version, provider, remote, s3) => {
|
||||
|
||||
module.exports.getDataDirectory = _getDataDirectory;
|
||||
|
||||
module.exports.getRepertoryDirectory = _getRepertoryDirectory;
|
||||
|
||||
module.exports.getMissingDependencies = dependencies => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!dependencies) {
|
||||
|
||||
@@ -30,6 +30,7 @@ if (ipcRenderer) {
|
||||
const providerList = [
|
||||
...Constants.PROVIDER_LIST,
|
||||
...store.getState().mounts.RemoteMounts,
|
||||
...store.getState().mounts.S3Mounts,
|
||||
];
|
||||
for (const provider of providerList) {
|
||||
let state = result.data[provider] || store.getState().mounts.ProviderState[provider];
|
||||
|
||||
@@ -71,13 +71,13 @@ export const loadReleases = () => {
|
||||
const state = getState().relver;
|
||||
let release = state.Release;
|
||||
if (release >= Constants.RELEASE_TYPES.length) {
|
||||
release = state.ReleaseDefault;
|
||||
release = Constants.DEFAULT_RELEASE;
|
||||
}
|
||||
|
||||
let latestVersion = versionLookup[Constants.RELEASE_TYPES[release]].length - 1;
|
||||
let version = state.Version;
|
||||
if (versionLookup[Constants.RELEASE_TYPES[release]][0] === 'unavailable') {
|
||||
release = state.ReleaseDefault;
|
||||
release = Constants.DEFAULT_RELEASE;
|
||||
version = latestVersion = versionLookup[Constants.RELEASE_TYPES[release]].length - 1
|
||||
} else if ((version === -1) || !versionLookup[Constants.RELEASE_TYPES[release]][version]) {
|
||||
version = latestVersion;
|
||||
@@ -179,7 +179,7 @@ export const setActiveRelease = (release, version) => {
|
||||
const relver = getState().relver;
|
||||
const common = getState().common;
|
||||
if (release >= Constants.RELEASE_TYPES.length) {
|
||||
release = relver.ReleaseDefault;
|
||||
release = Constants.DEFAULT_RELEASE;
|
||||
version = -1;
|
||||
}
|
||||
const versions = relver.VersionLookup[Constants.RELEASE_TYPES[release]];
|
||||
|
||||
@@ -20,8 +20,7 @@ export const releaseVersionReducer = createReducer({
|
||||
LocationsLookup: {},
|
||||
NewReleasesAvailable: [],
|
||||
NewReleasesAvailable2: [],
|
||||
Release: 0,
|
||||
ReleaseDefault: 0,
|
||||
Release: Constants.DEFAULT_RELEASE,
|
||||
ReleaseUpgradeAvailable: false,
|
||||
UpgradeAvailable: false,
|
||||
UpgradeData: null,
|
||||
|
||||
@@ -3,19 +3,55 @@ const fs = require('fs');
|
||||
const helpers = require('../../helpers');
|
||||
const path = require('path');
|
||||
|
||||
const getDirectories = source =>
|
||||
fs.readdirSync(source, {withFileTypes: true})
|
||||
.filter(dirent => dirent.isDirectory())
|
||||
.map(dirent => dirent.name)
|
||||
|
||||
const addListeners = ipcMain => {
|
||||
ipcMain.on(Constants.IPC_Get_State, event => {
|
||||
helpers.mkDirByPathSync(helpers.getDataDirectory());
|
||||
|
||||
let data = {};
|
||||
const configFile = path.join(helpers.getDataDirectory(), 'settings.json');
|
||||
if (fs.existsSync(configFile)) {
|
||||
event.sender.send(Constants.IPC_Get_State_Reply, {
|
||||
data: JSON.parse(fs.readFileSync(configFile, 'utf8')),
|
||||
});
|
||||
data = JSON.parse(fs.readFileSync(configFile, 'utf8'));
|
||||
} else {
|
||||
event.sender.send(Constants.IPC_Get_State_Reply, {
|
||||
data: null,
|
||||
});
|
||||
data.Release = Constants.DEFAULT_RELEASE;
|
||||
data.Version = -1;
|
||||
}
|
||||
|
||||
data.RemoteMounts = data.RemoteMounts || [];
|
||||
data.S3Mounts = data.S3Mounts || [];
|
||||
|
||||
const remoteItems = getDirectories(path.join(helpers.getRepertoryDirectory(), 'remote'));
|
||||
for (const dir of remoteItems) {
|
||||
const name = 'Remote' + dir.replace('_', ':');
|
||||
if (!data.RemoteMounts || data.RemoteMounts.indexOf(name) === -1) {
|
||||
data.RemoteMounts.push(name);
|
||||
data[name] = {
|
||||
AutoMount: false,
|
||||
AutoRestart: true,
|
||||
MountLocation: '',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const s3Items = getDirectories(path.join(helpers.getRepertoryDirectory(), 's3'));
|
||||
for (const dir of s3Items) {
|
||||
const name = 'S3' + dir;
|
||||
if (!data.S3Mounts || data.S3Mounts.indexOf(name) === -1) {
|
||||
data.S3Mounts.push(name);
|
||||
data[name] = {
|
||||
AutoMount: false,
|
||||
AutoRestart: true,
|
||||
MountLocation: '',
|
||||
};
|
||||
}
|
||||
}
|
||||
event.sender.send(Constants.IPC_Get_State_Reply, {
|
||||
data,
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on(Constants.IPC_Save_State, (event, data) => {
|
||||
|
||||
Reference in New Issue
Block a user