From 2536278c0ceedb85b3d1b1a51bb4b2c4e7b023fa Mon Sep 17 00:00:00 2001 From: solvedDev Date: Sat, 28 May 2022 16:30:28 +0200 Subject: [PATCH] fix: file imports being broken --- src/components/ImportFile/BasicFile.ts | 17 ++++++++--------- .../Windows/Common/FilePath/Window.ts | 7 ++++++- .../Windows/Project/CreatePreset/PresetPath.vue | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/components/ImportFile/BasicFile.ts b/src/components/ImportFile/BasicFile.ts index b7336ade9..bc6afef92 100644 --- a/src/components/ImportFile/BasicFile.ts +++ b/src/components/ImportFile/BasicFile.ts @@ -5,6 +5,7 @@ import { InformedChoiceWindow } from '/@/components/Windows/InformedChoice/Infor import { FilePathWindow } from '/@/components/Windows/Common/FilePath/Window' import { ConfirmationWindow } from '/@/components/Windows/Common/Confirm/ConfirmWindow' import { AnyFileHandle } from '../FileSystem/Types' +import { join } from '/@/utils/path' export class BasicFileImporter extends FileImporter { constructor(fileDropper: FileDropper) { @@ -67,7 +68,9 @@ export class BasicFileImporter extends FileImporter { // Allow user to change file path that the file is saved to const filePathWindow = new FilePathWindow({ fileName: fileHandle.name, - startPath: (await App.fileType.guessFolder(fileHandle)) ?? '', + startPath: app.project.relativePath( + (await App.fileType.guessFolder(fileHandle)) ?? '' + ), isPersistent: false, }) filePathWindow.open() @@ -75,11 +78,10 @@ export class BasicFileImporter extends FileImporter { const userInput = await filePathWindow.fired if (userInput === null) return const { filePath, fileName = fileHandle.name } = userInput + const newFilePath = join(filePath, fileName) // Get user confirmation if file overwrites already existing file - const fileExists = await app.project.fileSystem.fileExists( - `${filePath}${fileName}` - ) + const fileExists = await app.project.fileSystem.fileExists(newFilePath) if (fileExists) { const confirmWindow = new ConfirmationWindow({ description: 'windows.createPreset.overwriteFiles', @@ -93,7 +95,7 @@ export class BasicFileImporter extends FileImporter { app.windows.loadingWindow.open() const destHandle = await app.project.fileSystem.getFileHandle( - `${filePath}${fileName}`, + newFilePath, true ) @@ -101,10 +103,7 @@ export class BasicFileImporter extends FileImporter { App.eventSystem.dispatch('fileAdded', undefined) await app.project.updateFile( - app.project.config.resolvePackPath( - undefined, - `${filePath}${fileName}` - ) + app.project.config.resolvePackPath(undefined, newFilePath) ) await app.project.openFile(destHandle, { isTemporary: false }) diff --git a/src/components/Windows/Common/FilePath/Window.ts b/src/components/Windows/Common/FilePath/Window.ts index ec21cdc55..50d735a3a 100644 --- a/src/components/Windows/Common/FilePath/Window.ts +++ b/src/components/Windows/Common/FilePath/Window.ts @@ -42,7 +42,12 @@ export class FilePathWindow extends BaseWindow { return this.close( skippedDialog ? null - : { filePath: this.currentFilePath, fileName: this.hasFilePath ? `${this.fileName}${this.fileExt}` : undefined } + : { + filePath: this.currentFilePath, + fileName: this.hasFilePath + ? `${this.fileName}${this.fileExt}` + : undefined, + } ) } } diff --git a/src/components/Windows/Project/CreatePreset/PresetPath.vue b/src/components/Windows/Project/CreatePreset/PresetPath.vue index 70defb195..5121028f3 100644 --- a/src/components/Windows/Project/CreatePreset/PresetPath.vue +++ b/src/components/Windows/Project/CreatePreset/PresetPath.vue @@ -74,7 +74,7 @@ export default { }, computed: { path() { - return this.value.substring(0, this.value.length - 1) + return this.editedPath.substring(0, this.editedPath.length - 1) }, }, methods: {