From c9fb0a090b9c3420f3e84d0f08df9f3d15aefc54 Mon Sep 17 00:00:00 2001 From: Jochen Date: Thu, 11 Jun 2020 14:43:53 +0200 Subject: [PATCH] Do not trigger shar when upload failed due to missing credentials/permissions Issue #5 Signed-off-by: Jochen --- login.js | 18 +++++++++--------- package-lock.json | 2 +- package.json | 2 +- upload.js | 5 +++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/login.js b/login.js index 02b9547..2f92580 100644 --- a/login.js +++ b/login.js @@ -7,15 +7,6 @@ const login = context => { return new Promise((resolve, reject) => { const credentials = [] - const authWindow = new BrowserWindow({ - 'use-content-size': true, - alwaysOnTop: true, - autoHideMenuBar: false, - webPreferences: { - nodeIntegration: false - } - }) - /** * Register nc:// protocol */ @@ -42,6 +33,15 @@ const login = context => { console.error(error) }) + const authWindow = new BrowserWindow({ + 'use-content-size': true, + alwaysOnTop: true, + autoHideMenuBar: false, + webPreferences: { + nodeIntegration: false + } + }) + const extraHeaders = { userAgent: 'KapScreenRecorder', extraHeaders: 'OCS-APIREQUEST: true\n ACCEPT_LANGUAGE: "en-US"' diff --git a/package-lock.json b/package-lock.json index 060860d..6cbb025 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "kap-nextcloud", - "version": "1.4.2", + "version": "1.4.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index fe64a83..6f89f93 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kap-nextcloud", - "version": "1.4.2", + "version": "1.4.3", "description": "Upload Screencast to your Nextcloud Instance", "main": "index.js", "scripts": { diff --git a/upload.js b/upload.js index 84113eb..73aab81 100644 --- a/upload.js +++ b/upload.js @@ -25,13 +25,14 @@ const upload = (context, filePath) => { if (response.statusCode !== 201) { context.config.delete('username') context.config.delete('password') + } else { + context.setProgress('Upload finished', 'completed') + share(context, filePath) } if (error) { return console.error('Nextcloud upload failed:', error) } - context.setProgress('Upload finished', 'completed') - share(context, filePath) }) }