Skip to content

Commit

Permalink
Mobile: Plugin API: Fix error when calling plugins.dataDir (#10262)
Browse files Browse the repository at this point in the history
  • Loading branch information
personalizedrefrigerator authored Apr 4, 2024
1 parent 500c8fa commit 384b177
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/app-mobile/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ import ProfileSwitcher from './components/ProfileSwitcher/ProfileSwitcher';
import ProfileEditor from './components/ProfileSwitcher/ProfileEditor';
import sensorInfo, { SensorInfo } from './components/biometrics/sensorInfo';
import { getCurrentProfile } from '@joplin/lib/services/profileConfig';
import { getDatabaseName, getProfilesRootDir, getResourceDir, setDispatch } from './services/profiles';
import { getDatabaseName, getPluginDataDir, getProfilesRootDir, getResourceDir, setDispatch } from './services/profiles';
import userFetcher, { initializeUserFetcher } from '@joplin/lib/utils/userFetcher';
import { ReactNode } from 'react';
import { parseShareCache } from '@joplin/lib/services/share/reducer';
Expand Down Expand Up @@ -495,6 +495,7 @@ async function initialize(dispatch: Function) {
const resourceDir = getResourceDir(currentProfile, isSubProfile);
Setting.setConstant('resourceDir', resourceDir);
Setting.setConstant('pluginDir', `${getProfilesRootDir()}/plugins`);
Setting.setConstant('pluginDataDir', getPluginDataDir(currentProfile, isSubProfile));

await shim.fsDriver().mkdir(resourceDir);

Expand Down
5 changes: 5 additions & 0 deletions packages/app-mobile/services/profiles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export const getResourceDir = (profile: Profile, isSubProfile: boolean) => {
return `${getProfilesRootDir()}/resources-${profile.id}`;
};

export const getPluginDataDir = (profile: Profile, isSubProfile: boolean) => {
const suffix = isSubProfile ? `-${profile.id}` : '';
return `${getProfilesRootDir()}/plugin-data${suffix}`;
};

// The suffix is for debugging only
export const getDatabaseName = (profile: Profile, isSubProfile: boolean, suffix = '') => {
if (!isSubProfile) return `joplin${suffix}.sqlite`;
Expand Down

0 comments on commit 384b177

Please sign in to comment.