mirror of
https://github.com/sct/overseerr.git
synced 2025-12-26 16:27:17 +01:00
* fix: use fs/promises for settings This PR switches from synchronous operations with the 'fs' module to asynchronous operations with the 'fs/promises' module. It also corrects a small error with hostname migration. * fix: add missing merge function of default and current config * refactor: add more logs to migration
28 lines
849 B
TypeScript
28 lines
849 B
TypeScript
import type { AllSettings } from '@server/lib/settings';
|
|
|
|
const migrateHostname = (settings: any): AllSettings => {
|
|
if (settings.jellyfin?.hostname) {
|
|
const { hostname } = settings.jellyfin;
|
|
const protocolMatch = hostname.match(/^(https?):\/\//i);
|
|
const useSsl = protocolMatch && protocolMatch[1].toLowerCase() === 'https';
|
|
const remainingUrl = hostname.replace(/^(https?):\/\//i, '');
|
|
const urlMatch = remainingUrl.match(/^([^:]+)(:([0-9]+))?(\/.*)?$/);
|
|
|
|
delete settings.jellyfin.hostname;
|
|
if (urlMatch) {
|
|
const [, ip, , port, urlBase] = urlMatch;
|
|
settings.jellyfin = {
|
|
...settings.jellyfin,
|
|
ip,
|
|
port: port || (useSsl ? 443 : 80),
|
|
useSsl,
|
|
urlBase: urlBase ? urlBase.replace(/\/$/, '') : '',
|
|
};
|
|
}
|
|
}
|
|
|
|
return settings;
|
|
};
|
|
|
|
export default migrateHostname;
|