mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 11:42:19 +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 { mihomoProfileWorkDir, profileConfigPath, profilePath } from '../utils/dirs'
|
||||
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 { getAppConfig } from './app'
|
||||
import { existsSync } from 'fs'
|
||||
import axios, { AxiosResponse } from 'axios'
|
||||
import yaml from 'yaml'
|
||||
import path from 'path'
|
||||
import { defaultProfile } from '../utils/template'
|
||||
import { subStorePort } from '../resolve/server'
|
||||
|
||||
|
@ -94,18 +93,6 @@ export async function removeProfileItem(id: string): Promise<void> {
|
|||
await restartCore()
|
||||
}
|
||||
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 })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
overridePath
|
||||
} from '../utils/dirs'
|
||||
import yaml from 'yaml'
|
||||
import { link, mkdir, writeFile } from 'fs/promises'
|
||||
import { copyFile, mkdir, writeFile } from 'fs/promises'
|
||||
import { deepMerge } from '../utils/merge'
|
||||
import vm from 'vm'
|
||||
import { existsSync, writeFileSync } from 'fs'
|
||||
|
@ -47,15 +47,19 @@ async function prepareProfileWorkDir(current: string | undefined): Promise<void>
|
|||
if (!existsSync(mihomoProfileWorkDir(current))) {
|
||||
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 sourcePath = path.join(mihomoWorkDir(), file)
|
||||
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(
|
||||
|
|
Loading…
Reference in New Issue
Block a user