mirror of
https://github.com/modrinth/code.git
synced 2026-08-25 00:55:25 +00:00
fix: memory issues when importing giant mrpack files (#6278)
* feat: dont load mrpacks into memory if they are local imports * fix: frontend
This commit is contained in:
@@ -196,9 +196,11 @@ watch(
|
||||
)
|
||||
|
||||
async function triggerFileInput() {
|
||||
const picked = await filePicker.pickModpackFile()
|
||||
const picked = await filePicker.pickModpackFile({
|
||||
readFile: ctx.flowType !== 'instance',
|
||||
})
|
||||
if (picked) {
|
||||
ctx.modpackFile.value = picked.file
|
||||
ctx.modpackFile.value = picked.file ?? null
|
||||
ctx.modpackFilePath.value = picked.path ?? null
|
||||
proceedWithModpack()
|
||||
}
|
||||
|
||||
@@ -572,7 +572,7 @@ provideInstallationSettings({
|
||||
if (modpack.value.spec.platform === 'local_file') {
|
||||
debug('reinstallModpack: local file, opening file picker')
|
||||
const picked = await filePicker.pickModpackFile()
|
||||
if (!picked) return
|
||||
if (!picked?.file) return
|
||||
try {
|
||||
const handle = client.kyros.content_v1.uploadModpackFile(
|
||||
worldId.value!,
|
||||
|
||||
@@ -9,11 +9,21 @@ export interface PickedFile {
|
||||
previewUrl: string
|
||||
}
|
||||
|
||||
export interface PickedModpackFile extends Omit<PickedFile, 'file'> {
|
||||
/** Only present for upload flows; native imports avoid copying huge packs into the webview heap. */
|
||||
file?: File
|
||||
}
|
||||
|
||||
export interface PickModpackFileOptions {
|
||||
/** Set to false when a native path can be streamed directly by the backend. */
|
||||
readFile?: boolean
|
||||
}
|
||||
|
||||
export interface FilePickerProvider {
|
||||
/** Pick an image file (for icons) */
|
||||
pickImage: () => Promise<PickedFile | null>
|
||||
/** Pick a .mrpack modpack file */
|
||||
pickModpackFile: () => Promise<PickedFile | null>
|
||||
pickModpackFile: (options?: PickModpackFileOptions) => Promise<PickedModpackFile | null>
|
||||
}
|
||||
|
||||
export const [injectFilePicker, provideFilePicker] = createContext<FilePickerProvider>('FilePicker')
|
||||
|
||||
Reference in New Issue
Block a user