Skip to content

Commit 86c0033

Browse files
authored
Merge pull request #16 from BeanVortex/bug_fix
Bug fix
2 parents e0c101b + 53fc1d9 commit 86c0033

File tree

15 files changed

+91
-50
lines changed

15 files changed

+91
-50
lines changed

.github/workflows/ci_cd.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
branches:
55
- main
66
env:
7-
VERSION: 1.4.5
7+
VERSION: 1.4.6
88
EXT_VERSION: 1.0
99
NAME: BitKip
1010
jobs:

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
}
99

1010
group 'io.beanvortex'
11-
version '1.4.5'
11+
version '1.4.6'
1212
sourceCompatibility = '21'
1313
targetCompatibility = '21'
1414
mainClassName = 'io.beanvortex.bitkip.BitKip'

builders/linux-installer/application/BitKip.desktop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[Desktop Entry]
22
Name=BitKip
3-
Version=1.4.5
3+
Version=1.4.6
44
Comment=Free download manager
55
Keywords=download,java,app
66
Exec=/usr/share/BitKip/bin/BitKip

extensions/chrome_based/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"icon" : "./src/resources/icons/logo.png"
66
},
77
"manifest_version": 3,
8-
"version": "1.0",
8+
"version": "1.1",
99
"description": "Download grabber that works with BitKip application",
1010
"host_permissions": ["*://*/*"],
1111
"permissions": [

extensions/chrome_based/src/scripts/connector.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ const postLinks = async (data, isBatch) => {
4949
fetch(URL_TO_POST, {
5050
method: 'POST',
5151
body: JSON.stringify(data),
52-
}).catch(_ => {
52+
}).catch(async _ => {
5353
chrome.notifications.create('', {
5454
title: 'BitKip Extension',
5555
message: "Can't send url to BitKip, Is application running on the same port?",
5656
iconUrl: '../resources/icons/logo.png',
5757
type: 'basic'
5858
});
59-
chrome.downloads.download({url: data.url})
59+
chrome.downloads.onDeterminingFilename.removeListener(triggerDownload)
60+
await chrome.downloads.download({url: data.url})
61+
chrome.downloads.onDeterminingFilename.addListener(triggerDownload)
6062
});
6163
}
6264

extensions/firefox/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"manifest_version": 3,
3-
"version": "1.0",
3+
"version": "1.1",
44
"name": "BitKip extension",
55

66
"action": {

extensions/firefox/src/scripts/connector.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,16 @@ const postLinks = async (data, isBatch) => {
5050
method: 'POST',
5151
mode: "cors",
5252
body: JSON.stringify(data),
53-
}).catch(_ => {
53+
}).catch(async _ => {
5454
browser.notifications.create('', {
5555
title: 'BitKip Extension',
5656
message: "Can't send url to BitKip, Is application running on the same port?",
5757
iconUrl: '../resources/icons/logo.png',
5858
type: 'basic'
5959
});
60-
browser.downloads.download({url: data.url})
60+
browser.downloads.onCreated.removeListener(triggerDownload)
61+
await browser.downloads.download({url: data.url})
62+
browser.downloads.onCreated.addListener(triggerDownload)
6163
});
6264
}
6365

@@ -94,12 +96,12 @@ browser.runtime.onMessage.addListener(async (message, sender, sendResponse) => {
9496
const triggerDownload = (downloadItem) => {
9597
// final url is used when url itself is a redirecting link
9698
updateEnable();
97-
if (!enabled || (downloadItem.mime && downloadItem.mime.includes("image")))
99+
if (!enabled || (downloadItem.mime && downloadItem.mime.includes("image")))
98100
return;
99101
let url = downloadItem.finalUrl || downloadItem.url;
100102
if (isSupportedProtocol(url)) {
101103
let filename = downloadItem.filename;
102-
if (filename.includes('/')){
104+
if (filename.includes('/')) {
103105
const start = downloadItem.filename.lastIndexOf('/');
104106
filename = downloadItem.filename.substring(start === -1 ? 0 : start + 1);
105107
}

src/main/java/io/beanvortex/bitkip/config/AppConfigs.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
public class AppConfigs {
1919

20-
public static final String VERSION = "1.4.5";
20+
public static final String VERSION = "1.4.6";
2121

2222
public static final String dataPath = System.getProperty("user.home")
2323
+ File.separator + "Documents"
@@ -61,6 +61,7 @@ public class AppConfigs {
6161
public static boolean addSameDownload = defaultAddSameDownload;
6262
public static final boolean defaultLessCpuIntensive = false;
6363
public static boolean lessCpuIntensive = defaultLessCpuIntensive;
64+
public static String lastSavedDir = null;
6465

6566

6667

src/main/java/io/beanvortex/bitkip/controllers/BatchDownload.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.beanvortex.bitkip.controllers;
22

3+
import io.beanvortex.bitkip.config.AppConfigs;
34
import io.beanvortex.bitkip.utils.FxUtils;
45
import io.beanvortex.bitkip.config.observers.QueueObserver;
56
import io.beanvortex.bitkip.config.observers.QueueSubject;
@@ -12,10 +13,7 @@
1213
import javafx.application.Platform;
1314
import javafx.event.ActionEvent;
1415
import javafx.fxml.FXML;
15-
import javafx.scene.control.Button;
16-
import javafx.scene.control.ComboBox;
17-
import javafx.scene.control.Label;
18-
import javafx.scene.control.TextField;
16+
import javafx.scene.control.*;
1917
import javafx.stage.Stage;
2018
import org.kordamp.ikonli.javafx.FontIcon;
2119

@@ -46,7 +44,8 @@ public class BatchDownload implements QueueObserver {
4644
private ComboBox<QueueModel> queueCombo;
4745
@FXML
4846
private TextField chunksField, urlField;
49-
47+
@FXML
48+
private CheckBox lastLocationCheck;
5049

5150
private LinkModel tempLink;
5251
private Stage stage;
@@ -79,6 +78,7 @@ public void initialize(URL location, ResourceBundle resources) {
7978
queueCombo.setValue(queues.get(0));
8079
errorLabel.setVisible(false);
8180
checkBtn.setDisable(true);
81+
lastLocationCheck.setDisable(true);
8282
Validations.prepareLinkFromClipboard(urlField);
8383
Validations.validateChunksInput(chunksField);
8484
Validations.validateIntInputCheck(startField, 0L, 0, null);
@@ -109,7 +109,7 @@ public void initialize(URL location, ResourceBundle resources) {
109109
private void onOfflineFieldsChanged() {
110110
if (tempLink != null)
111111
handleError(() -> DownloadUtils.onOfflineFieldsChanged(locationField, tempLink.getName(),
112-
null, queueCombo, null, checkBtn, openLocation, null), errorLabel);
112+
null, queueCombo, null, checkBtn, openLocation, null, lastLocationCheck), errorLabel);
113113

114114
}
115115

@@ -128,7 +128,7 @@ private void autoFillLocation() {
128128
fileNameLocationFuture
129129
.whenComplete((unused, throwable) ->
130130
handleError(() -> DownloadUtils.checkIfFileIsOKToSave(locationField.getText(),
131-
tempLink.getName(), null, checkBtn, null), errorLabel))
131+
tempLink.getName(), null, checkBtn, null, lastLocationCheck), errorLabel))
132132
.exceptionally(throwable -> {
133133
var errorMsg = throwable.getCause().getLocalizedMessage();
134134
Platform.runLater(() ->
@@ -231,7 +231,7 @@ private void onSelectLocation(ActionEvent e) {
231231
locationField.setText(path);
232232
if (tempLink != null)
233233
handleError(() -> DownloadUtils.checkIfFileIsOKToSave(locationField.getText(),
234-
tempLink.getName(), null, checkBtn, null), errorLabel);
234+
tempLink.getName(), null, checkBtn, null, lastLocationCheck), errorLabel);
235235
}
236236

237237
@FXML
@@ -341,6 +341,13 @@ private void onQueueChanged() {
341341
onOfflineFieldsChanged();
342342
}
343343

344+
@FXML
345+
private void onLastLocationCheck() {
346+
if (lastLocationCheck.isSelected())
347+
locationField.setText(AppConfigs.lastSavedDir);
348+
else
349+
setLocation(tempLink.getName());
350+
}
344351
}
345352

346353

src/main/java/io/beanvortex/bitkip/controllers/SingleDownload.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
import javafx.application.Platform;
1111
import javafx.event.ActionEvent;
1212
import javafx.fxml.FXML;
13-
import javafx.scene.control.Button;
14-
import javafx.scene.control.ComboBox;
15-
import javafx.scene.control.Label;
16-
import javafx.scene.control.TextField;
13+
import javafx.scene.control.*;
1714
import javafx.stage.Stage;
1815
import org.kordamp.ikonli.javafx.FontIcon;
1916

@@ -29,6 +26,8 @@
2926

3027
public class SingleDownload implements QueueObserver {
3128

29+
@FXML
30+
private CheckBox lastLocationCheck;
3231
@FXML
3332
private Label sizeLabel, resumableLabel, errorLabel;
3433
@FXML
@@ -78,6 +77,7 @@ public void initialize(URL location, ResourceBundle resources) {
7877
refreshBtn.setGraphic(new FontIcon());
7978
refreshBtn.setDisable(true);
8079
refreshBtn.setVisible(false);
80+
lastLocationCheck.setDisable(true);
8181
refreshBtn.setOnAction(e -> {
8282
refreshBtn.setDisable(true);
8383
refreshBtn.setVisible(false);
@@ -162,14 +162,14 @@ private void autoFillLocationAndSizeAndName() {
162162
var connection = DownloadUtils.connect(url);
163163
var executor = Executors.newVirtualThreadPerTaskExecutor();
164164
var fileNameLocationFuture =
165-
DownloadUtils.prepareFileNameAndFieldsAsync(connection, url, nameField, executor)
165+
DownloadUtils.prepareFileNameAndFieldsAsync(connection, url, nameField, dm, executor)
166166
.thenAccept(this::setLocation);
167167
var sizeFuture = DownloadUtils.prepareFileSizeAndFieldsAsync(connection,
168168
urlField, sizeLabel, resumableLabel, speedField, chunksField, bytesField, dm, executor);
169169
CompletableFuture.allOf(fileNameLocationFuture, sizeFuture)
170170
.whenComplete((unused, throwable) -> {
171171
DownloadUtils.handleError(() -> DownloadUtils.checkIfFileIsOKToSave(locationField.getText(),
172-
nameField.getText(), downloadBtn, addBtn, refreshBtn), errorLabel);
172+
nameField.getText(), downloadBtn, addBtn, refreshBtn, lastLocationCheck), errorLabel);
173173
executor.shutdown();
174174
})
175175
.exceptionally(throwable -> {
@@ -195,7 +195,15 @@ private void onSelectLocation(ActionEvent e) {
195195
if (path != null)
196196
locationField.setText(path);
197197
DownloadUtils.handleError(() -> DownloadUtils.checkIfFileIsOKToSave(locationField.getText(),
198-
nameField.getText(), downloadBtn, addBtn, refreshBtn), errorLabel);
198+
nameField.getText(), downloadBtn, addBtn, refreshBtn, lastLocationCheck), errorLabel);
199+
}
200+
201+
@FXML
202+
private void onLastLocationCheck() {
203+
if (lastLocationCheck.isSelected())
204+
locationField.setText(AppConfigs.lastSavedDir);
205+
else
206+
setLocation(dm.getName());
199207
}
200208

201209
@FXML
@@ -314,7 +322,7 @@ private void onQueueChanged() {
314322

315323
private void onOfflineFieldsChanged() {
316324
DownloadUtils.handleError(() -> DownloadUtils.onOfflineFieldsChanged(locationField, nameField.getText(), dm, queueCombo,
317-
downloadBtn, addBtn, openLocation, refreshBtn), errorLabel);
325+
downloadBtn, addBtn, openLocation, refreshBtn, lastLocationCheck), errorLabel);
318326
}
319327

320328

@@ -323,4 +331,5 @@ public void setUrlModel(SingleURLModel urlModel) {
323331
initAfterUrlModel();
324332
}
325333

334+
326335
}

0 commit comments

Comments
 (0)