mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
use copy instead of link
This commit is contained in:
parent
65149c33da
commit
ad0a5c7932
@ -1,13 +1,12 @@
|
|||||||
import { getControledMihomoConfig } from './controledMihomo'
|
import { getControledMihomoConfig } from './controledMihomo'
|
||||||
import { mihomoProfileWorkDir, profileConfigPath, profilePath } from '../utils/dirs'
|
import { mihomoProfileWorkDir, profileConfigPath, profilePath } from '../utils/dirs'
|
||||||
import { addProfileUpdater } from '../core/profileUpdater'
|
import { addProfileUpdater } from '../core/profileUpdater'
|
||||||
import { readFile, rm, unlink, writeFile } from 'fs/promises'
|
import { readFile, rm, writeFile } from 'fs/promises'
|
||||||
import { restartCore } from '../core/manager'
|
import { restartCore } from '../core/manager'
|
||||||
import { getAppConfig } from './app'
|
import { getAppConfig } from './app'
|
||||||
import { existsSync } from 'fs'
|
import { existsSync } from 'fs'
|
||||||
import axios, { AxiosResponse } from 'axios'
|
import axios, { AxiosResponse } from 'axios'
|
||||||
import yaml from 'yaml'
|
import yaml from 'yaml'
|
||||||
import path from 'path'
|
|
||||||
import { defaultProfile } from '../utils/template'
|
import { defaultProfile } from '../utils/template'
|
||||||
import { subStorePort } from '../resolve/server'
|
import { subStorePort } from '../resolve/server'
|
||||||
|
|
||||||
@ -94,18 +93,6 @@ export async function removeProfileItem(id: string): Promise<void> {
|
|||||||
await restartCore()
|
await restartCore()
|
||||||
}
|
}
|
||||||
if (existsSync(mihomoProfileWorkDir(id))) {
|
if (existsSync(mihomoProfileWorkDir(id))) {
|
||||||
const unln = async (file: string): Promise<void> => {
|
|
||||||
const targetPath = path.join(mihomoProfileWorkDir(id), file)
|
|
||||||
if (existsSync(targetPath)) {
|
|
||||||
await unlink(targetPath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await Promise.all([
|
|
||||||
unln('country.mmdb'),
|
|
||||||
unln('geoip.dat'),
|
|
||||||
unln('geosite.dat'),
|
|
||||||
unln('ASN.mmdb')
|
|
||||||
])
|
|
||||||
await rm(mihomoProfileWorkDir(id), { recursive: true })
|
await rm(mihomoProfileWorkDir(id), { recursive: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import {
|
|||||||
overridePath
|
overridePath
|
||||||
} from '../utils/dirs'
|
} from '../utils/dirs'
|
||||||
import yaml from 'yaml'
|
import yaml from 'yaml'
|
||||||
import { link, mkdir, writeFile } from 'fs/promises'
|
import { copyFile, mkdir, writeFile } from 'fs/promises'
|
||||||
import { deepMerge } from '../utils/merge'
|
import { deepMerge } from '../utils/merge'
|
||||||
import vm from 'vm'
|
import vm from 'vm'
|
||||||
import { existsSync, writeFileSync } from 'fs'
|
import { existsSync, writeFileSync } from 'fs'
|
||||||
@ -47,15 +47,19 @@ async function prepareProfileWorkDir(current: string | undefined): Promise<void>
|
|||||||
if (!existsSync(mihomoProfileWorkDir(current))) {
|
if (!existsSync(mihomoProfileWorkDir(current))) {
|
||||||
await mkdir(mihomoProfileWorkDir(current), { recursive: true })
|
await mkdir(mihomoProfileWorkDir(current), { recursive: true })
|
||||||
}
|
}
|
||||||
const ln = async (file: string): Promise<void> => {
|
const copy = async (file: string): Promise<void> => {
|
||||||
const targetPath = path.join(mihomoProfileWorkDir(current), file)
|
const targetPath = path.join(mihomoProfileWorkDir(current), file)
|
||||||
|
|
||||||
const sourcePath = path.join(mihomoWorkDir(), file)
|
const sourcePath = path.join(mihomoWorkDir(), file)
|
||||||
if (!existsSync(targetPath) && existsSync(sourcePath)) {
|
if (!existsSync(targetPath) && existsSync(sourcePath)) {
|
||||||
await link(sourcePath, targetPath)
|
await copyFile(sourcePath, targetPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await Promise.all([ln('country.mmdb'), ln('geoip.dat'), ln('geosite.dat'), ln('ASN.mmdb')])
|
await Promise.all([
|
||||||
|
copy('country.mmdb'),
|
||||||
|
copy('geoip.dat'),
|
||||||
|
copy('geosite.dat'),
|
||||||
|
copy('ASN.mmdb')
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
async function overrideProfile(
|
async function overrideProfile(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user