mirror of
https://github.com/readest/readest.git
synced 2026-07-09 16:00:16 +00:00
fix(node-app-service): ensure correct cross-platform path resolution in NodeAppService (#4819)
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (rust) (push) Waiting to run
Publish Docker image / build (linux/amd64, ubuntu-latest) (push) Waiting to run
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Publish Docker image / merge (push) Blocked by required conditions
PR checks / rust_lint (push) Waiting to run
PR checks / build_web_app (push) Waiting to run
PR checks / test_web_app (1) (push) Waiting to run
PR checks / test_web_app (2) (push) Waiting to run
PR checks / test_extensions (push) Waiting to run
PR checks / build_tauri_app (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Deploy to vercel on merge / build_and_deploy (push) Waiting to run
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (rust) (push) Waiting to run
Publish Docker image / build (linux/amd64, ubuntu-latest) (push) Waiting to run
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Publish Docker image / merge (push) Blocked by required conditions
PR checks / rust_lint (push) Waiting to run
PR checks / build_web_app (push) Waiting to run
PR checks / test_web_app (1) (push) Waiting to run
PR checks / test_web_app (2) (push) Waiting to run
PR checks / test_extensions (push) Waiting to run
PR checks / build_tauri_app (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Deploy to vercel on merge / build_and_deploy (push) Waiting to run
* refactor(node): use path.join() in path resolver * fix(node): use native path separators in resolveFilePath.
This commit is contained in:
parent
348c85f648
commit
9496de301b
1 changed files with 18 additions and 14 deletions
|
|
@ -109,7 +109,7 @@ const getPathResolver = ({ customRootDir }: { customRootDir?: string } = {}) =>
|
|||
'Dictionaries',
|
||||
];
|
||||
const leafDir = dataDirs.includes(base) ? '' : base;
|
||||
return leafDir ? `${customRootDir}/${leafDir}` : customRootDir!;
|
||||
return leafDir ? nodePath.join(customRootDir!, leafDir) : customRootDir!;
|
||||
}
|
||||
: undefined;
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ const getPathResolver = ({ customRootDir }: { customRootDir?: string } = {}) =>
|
|||
return {
|
||||
baseDir: 0,
|
||||
basePrefix: async () => custom ?? getAppConfigDir(),
|
||||
fp: custom ? `${custom}${fp ? `/${fp}` : ''}` : fp,
|
||||
fp: custom ? nodePath.join(custom, fp) : fp,
|
||||
base,
|
||||
};
|
||||
case 'Cache':
|
||||
|
|
@ -134,16 +134,14 @@ const getPathResolver = ({ customRootDir }: { customRootDir?: string } = {}) =>
|
|||
return {
|
||||
baseDir: 0,
|
||||
basePrefix: async () => custom ?? getAppLogDir(),
|
||||
fp: custom ? `${custom}${fp ? `/${fp}` : ''}` : fp,
|
||||
fp: custom ? nodePath.join(custom, fp) : fp,
|
||||
base,
|
||||
};
|
||||
case 'Data':
|
||||
return {
|
||||
baseDir: 0,
|
||||
basePrefix: async () => custom ?? getAppDataDir(),
|
||||
fp: custom
|
||||
? `${custom}/${DATA_SUBDIR}${fp ? `/${fp}` : ''}`
|
||||
: `${DATA_SUBDIR}${fp ? `/${fp}` : ''}`,
|
||||
fp: custom ? nodePath.join(custom, DATA_SUBDIR, fp) : nodePath.join(DATA_SUBDIR, fp),
|
||||
base,
|
||||
};
|
||||
case 'Books':
|
||||
|
|
@ -151,8 +149,8 @@ const getPathResolver = ({ customRootDir }: { customRootDir?: string } = {}) =>
|
|||
baseDir: 0,
|
||||
basePrefix: async () => custom ?? getAppDataDir(),
|
||||
fp: custom
|
||||
? `${custom}/${LOCAL_BOOKS_SUBDIR}${fp ? `/${fp}` : ''}`
|
||||
: `${LOCAL_BOOKS_SUBDIR}${fp ? `/${fp}` : ''}`,
|
||||
? nodePath.join(custom, LOCAL_BOOKS_SUBDIR, fp)
|
||||
: nodePath.join(LOCAL_BOOKS_SUBDIR, fp),
|
||||
base,
|
||||
};
|
||||
case 'Fonts':
|
||||
|
|
@ -160,8 +158,8 @@ const getPathResolver = ({ customRootDir }: { customRootDir?: string } = {}) =>
|
|||
baseDir: 0,
|
||||
basePrefix: async () => custom ?? getAppDataDir(),
|
||||
fp: custom
|
||||
? `${custom}/${LOCAL_FONTS_SUBDIR}${fp ? `/${fp}` : ''}`
|
||||
: `${LOCAL_FONTS_SUBDIR}${fp ? `/${fp}` : ''}`,
|
||||
? nodePath.join(custom, LOCAL_FONTS_SUBDIR, fp)
|
||||
: nodePath.join(LOCAL_FONTS_SUBDIR, fp),
|
||||
base,
|
||||
};
|
||||
case 'Images':
|
||||
|
|
@ -169,8 +167,8 @@ const getPathResolver = ({ customRootDir }: { customRootDir?: string } = {}) =>
|
|||
baseDir: 0,
|
||||
basePrefix: async () => custom ?? getAppDataDir(),
|
||||
fp: custom
|
||||
? `${custom}/${LOCAL_IMAGES_SUBDIR}${fp ? `/${fp}` : ''}`
|
||||
: `${LOCAL_IMAGES_SUBDIR}${fp ? `/${fp}` : ''}`,
|
||||
? nodePath.join(custom, LOCAL_IMAGES_SUBDIR, fp)
|
||||
: nodePath.join(LOCAL_IMAGES_SUBDIR, fp),
|
||||
base,
|
||||
};
|
||||
case 'Dictionaries':
|
||||
|
|
@ -178,8 +176,8 @@ const getPathResolver = ({ customRootDir }: { customRootDir?: string } = {}) =>
|
|||
baseDir: 0,
|
||||
basePrefix: async () => custom ?? getAppDataDir(),
|
||||
fp: custom
|
||||
? `${custom}/${LOCAL_DICTIONARIES_SUBDIR}${fp ? `/${fp}` : ''}`
|
||||
: `${LOCAL_DICTIONARIES_SUBDIR}${fp ? `/${fp}` : ''}`,
|
||||
? nodePath.join(custom, LOCAL_DICTIONARIES_SUBDIR, fp)
|
||||
: nodePath.join(LOCAL_DICTIONARIES_SUBDIR, fp),
|
||||
base,
|
||||
};
|
||||
case 'None':
|
||||
|
|
@ -367,6 +365,12 @@ export class NodeAppService extends BaseAppService {
|
|||
return this.fs.resolvePath(fp, base);
|
||||
}
|
||||
|
||||
override async resolveFilePath(path: string, base: BaseDir): Promise<string> {
|
||||
const prefix = await this.fs.getPrefix(base);
|
||||
if (!path) return prefix;
|
||||
return prefix ? nodePath.join(prefix, path) : path;
|
||||
}
|
||||
|
||||
async init(): Promise<void> {
|
||||
await this.prepareBooksDir();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue