From 951b83c47c9343b19182308ba21dc9dc7bd6ad04 Mon Sep 17 00:00:00 2001 From: Natacha De la Rosa Date: Mon, 26 Sep 2022 09:53:47 -0400 Subject: [PATCH 1/7] fix(plot): change default plots dir --- src/components/mainMenu.vue | 2 +- src/pages/SetupPlot.vue | 5 ++++- src/shims-vue.d.ts | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/mainMenu.vue b/src/components/mainMenu.vue index 064ca2e1..6be2839a 100644 --- a/src/components/mainMenu.vue +++ b/src/components/mainMenu.vue @@ -113,7 +113,7 @@ export default defineComponent({ try { const log_path = await util.getLogPath(); util.infoLogger('log path acquired:' + log_path); - await tauri.invoke("open_folder", {dir: log_path}); + await tauri.invoke('open_folder', {dir: log_path}); } catch (error) { // TODO: add proper error handling - update store and show error page util.errorLogger(error); diff --git a/src/pages/SetupPlot.vue b/src/pages/SetupPlot.vue index c60ff62b..4d0f4d68 100644 --- a/src/pages/SetupPlot.vue +++ b/src/pages/SetupPlot.vue @@ -228,7 +228,7 @@ export default defineComponent({ }, async mounted() { await this.updateDriveStats(); - const path = (await tauri.path.dataDir()) + util.appName; + const path = (await tauri.path.dataDir()) + util.appName + '/plots'; this.store.setPlotPath(path); }, async created() { @@ -248,6 +248,8 @@ export default defineComponent({ methods: { async confirmCreateDir() { const dirExists = await native.dirExists(this.store.plotPath); + console.log('🚀 ~ file: SetupPlot.vue ~ line 251 ~ confirmCreateDir ~ this.store.plotPath', this.store.plotPath); + console.log('🚀 ~ file: SetupPlot.vue ~ line 251 ~ confirmCreateDir ~ dirExists', dirExists); if (dirExists) { util.infoLogger('SETUP PLOT | found the old plotting directory'); @@ -258,6 +260,7 @@ export default defineComponent({ }); if (files) { + console.log('🚀 ~ file: SetupPlot.vue ~ line 262 ~ confirmCreateDir ~ files', files); console.log('FILES ARE: :', files); if (files.length === 0 || (files.length === 1 && files.some(item => item.name === 'subspace-desktop.cfg'))) { directoryDialogs.existingDirectoryConfirm(this.store.plotPath, this.startPlotting); diff --git a/src/shims-vue.d.ts b/src/shims-vue.d.ts index 26163c40..19479361 100644 --- a/src/shims-vue.d.ts +++ b/src/shims-vue.d.ts @@ -1,6 +1,6 @@ // Mocks all files ending in `.vue` showing them as plain Vue instances declare module '*.vue' { - import { ComponentOptions } from 'vue' - const component: ComponentOptions - export default component + import { ComponentOptions } from 'vue'; + const component: ComponentOptions; + export default component; } From d73038dc6b9f6ec0146b36d900ed44f1b9156234 Mon Sep 17 00:00:00 2001 From: Natacha De la Rosa Date: Mon, 26 Sep 2022 09:57:47 -0400 Subject: [PATCH 2/7] fix(plot): remove console logs --- src/pages/SetupPlot.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pages/SetupPlot.vue b/src/pages/SetupPlot.vue index 4d0f4d68..ffa34256 100644 --- a/src/pages/SetupPlot.vue +++ b/src/pages/SetupPlot.vue @@ -248,8 +248,6 @@ export default defineComponent({ methods: { async confirmCreateDir() { const dirExists = await native.dirExists(this.store.plotPath); - console.log('🚀 ~ file: SetupPlot.vue ~ line 251 ~ confirmCreateDir ~ this.store.plotPath', this.store.plotPath); - console.log('🚀 ~ file: SetupPlot.vue ~ line 251 ~ confirmCreateDir ~ dirExists', dirExists); if (dirExists) { util.infoLogger('SETUP PLOT | found the old plotting directory'); @@ -260,7 +258,6 @@ export default defineComponent({ }); if (files) { - console.log('🚀 ~ file: SetupPlot.vue ~ line 262 ~ confirmCreateDir ~ files', files); console.log('FILES ARE: :', files); if (files.length === 0 || (files.length === 1 && files.some(item => item.name === 'subspace-desktop.cfg'))) { directoryDialogs.existingDirectoryConfirm(this.store.plotPath, this.startPlotting); From 5efe17b6effbd2850e8aec46d783175b0009a79b Mon Sep 17 00:00:00 2001 From: Natacha De la Rosa Date: Mon, 26 Sep 2022 15:49:27 -0400 Subject: [PATCH 3/7] fix(plot): use constant for folder name --- src/lib/util/index.ts | 1 + src/lib/util/util.ts | 2 ++ src/pages/SetupPlot.vue | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/util/index.ts b/src/lib/util/index.ts index c2b4bf44..a9434746 100644 --- a/src/lib/util/index.ts +++ b/src/lib/util/index.ts @@ -5,6 +5,7 @@ export { PIECE_SIZE, GB, CONTEXT_MENU, + PLOT_FOLDER, createApi, generateNodeName, getErrorMessage, diff --git a/src/lib/util/util.ts b/src/lib/util/util.ts index 5dbc7001..8a54d7dc 100644 --- a/src/lib/util/util.ts +++ b/src/lib/util/util.ts @@ -116,3 +116,5 @@ export function getErrorMessage(error: unknown): string | undefined { return; } } + +export const PLOT_FOLDER = '/plots'; \ No newline at end of file diff --git a/src/pages/SetupPlot.vue b/src/pages/SetupPlot.vue index ffa34256..605d95d2 100644 --- a/src/pages/SetupPlot.vue +++ b/src/pages/SetupPlot.vue @@ -228,7 +228,7 @@ export default defineComponent({ }, async mounted() { await this.updateDriveStats(); - const path = (await tauri.path.dataDir()) + util.appName + '/plots'; + const path = (await tauri.path.dataDir()) + util.appName + util.PLOT_FOLDER; this.store.setPlotPath(path); }, async created() { From dfcca2cfa8294fe911d9f69f23e86a1d9d03a595 Mon Sep 17 00:00:00 2001 From: Natacha De la Rosa Date: Wed, 28 Sep 2022 06:46:10 -0400 Subject: [PATCH 4/7] fix(plot): create plot folder if not found, reframe file checks --- src/pages/SetupPlot.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/SetupPlot.vue b/src/pages/SetupPlot.vue index 605d95d2..49cbd030 100644 --- a/src/pages/SetupPlot.vue +++ b/src/pages/SetupPlot.vue @@ -259,7 +259,7 @@ export default defineComponent({ if (files) { console.log('FILES ARE: :', files); - if (files.length === 0 || (files.length === 1 && files.some(item => item.name === 'subspace-desktop.cfg'))) { + if (files.length === 0) { directoryDialogs.existingDirectoryConfirm(this.store.plotPath, this.startPlotting); // we are in FIRST TIME START, meaning there is are no existing plot // if there are some files in this folder, it's weird @@ -288,6 +288,14 @@ export default defineComponent({ this.$router.replace({ name: 'plottingProgress' }); }, async updateDriveStats() { + const dirExists = await native.dirExists(this.store.plotPath); + + if (!dirExists) { + await tauri.fs.createDir(this.store.plotPath).catch((error) => { + util.errorLogger(error); + }); + } + const stats = await native.driveStats(this.store.plotPath); util.infoLogger('Drive Stats -> free: ' + stats.freeBytes + '; total: ' + stats.totalBytes); this.driveStats = stats; From 99af05a6215cdd173035c2f3528af0699085d4aa Mon Sep 17 00:00:00 2001 From: Natacha De la Rosa Date: Wed, 28 Sep 2022 07:09:45 -0400 Subject: [PATCH 5/7] fix(plot): update to keep console clean of red entries --- src/pages/SetupPlot.vue | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pages/SetupPlot.vue b/src/pages/SetupPlot.vue index 49cbd030..26f46d87 100644 --- a/src/pages/SetupPlot.vue +++ b/src/pages/SetupPlot.vue @@ -288,14 +288,6 @@ export default defineComponent({ this.$router.replace({ name: 'plottingProgress' }); }, async updateDriveStats() { - const dirExists = await native.dirExists(this.store.plotPath); - - if (!dirExists) { - await tauri.fs.createDir(this.store.plotPath).catch((error) => { - util.errorLogger(error); - }); - } - const stats = await native.driveStats(this.store.plotPath); util.infoLogger('Drive Stats -> free: ' + stats.freeBytes + '; total: ' + stats.totalBytes); this.driveStats = stats; @@ -309,6 +301,15 @@ export default defineComponent({ if (result) { this.store.setPlotPath(result); } + + const dirExists = await native.dirExists(this.store.plotPath); + + if (!dirExists) { + await tauri.fs.createDir(this.store.plotPath).catch((error) => { + util.errorLogger(error); + }); + } + await this.updateDriveStats(); }, } From 63ec79ac80709c47051f90927f0535d39c7b1e83 Mon Sep 17 00:00:00 2001 From: Natacha De la Rosa Date: Wed, 28 Sep 2022 11:16:11 -0400 Subject: [PATCH 6/7] fix(plot): create default plot folder --- src/pages/SetupPlot.vue | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/pages/SetupPlot.vue b/src/pages/SetupPlot.vue index 26f46d87..f22821dc 100644 --- a/src/pages/SetupPlot.vue +++ b/src/pages/SetupPlot.vue @@ -230,6 +230,7 @@ export default defineComponent({ await this.updateDriveStats(); const path = (await tauri.path.dataDir()) + util.appName + util.PLOT_FOLDER; this.store.setPlotPath(path); + this.createDefaultPlotDir(); }, async created() { this.$watch( @@ -301,17 +302,13 @@ export default defineComponent({ if (result) { this.store.setPlotPath(result); } - - const dirExists = await native.dirExists(this.store.plotPath); - - if (!dirExists) { - await tauri.fs.createDir(this.store.plotPath).catch((error) => { - util.errorLogger(error); - }); - } - await this.updateDriveStats(); }, + async createDefaultPlotDir() { + await tauri.fs.createDir(this.store.plotPath).catch((error) => { + util.errorLogger(error); + }); + }, } }); From 52fa88f76ecbf86530caa20ea1f735a12c023bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCn=20=C3=96zerk?= Date: Thu, 29 Sep 2022 15:08:48 +0300 Subject: [PATCH 7/7] missing await --- src/pages/SetupPlot.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/SetupPlot.vue b/src/pages/SetupPlot.vue index f22821dc..d9ee29d4 100644 --- a/src/pages/SetupPlot.vue +++ b/src/pages/SetupPlot.vue @@ -230,7 +230,7 @@ export default defineComponent({ await this.updateDriveStats(); const path = (await tauri.path.dataDir()) + util.appName + util.PLOT_FOLDER; this.store.setPlotPath(path); - this.createDefaultPlotDir(); + await this.createDefaultPlotDir(); }, async created() { this.$watch(