Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit 21853e9

Browse files
committed
修复已知BUG
1 parent 702af36 commit 21853e9

File tree

8 files changed

+50
-13
lines changed

8 files changed

+50
-13
lines changed

src/main/java/com/zhazhapan/qiniu/Downloader.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public class Downloader {
3232
* 下载文件
3333
*/
3434
public void downloadFromNet(String downloadURL) {
35+
if (Checker.isHyperLink(downloadURL)) {
36+
logger.info(downloadURL + " is a validated url");
37+
} else {
38+
logger.info(downloadURL + " is an invalidated url, can't download");
39+
return;
40+
}
3541
if (!checkDownloadPath()) {
3642
QiniuApplication.downloadPath = Dialogs.showInputDialog(null, Values.CONFIG_DOWNLOAD_PATH,
3743
System.getProperty("user.home"));

src/main/java/com/zhazhapan/qiniu/QiManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,11 @@ public void deleteFiles(ObservableList<FileInfo> fileInfos, String bucket) {
211211
public void listFileOfBucket() {
212212
MainWindowController main = MainWindowController.getInstance();
213213
// 列举空间文件列表
214-
BucketManager.FileListIterator iterator = QiniuApplication.bucketManager
215-
.createFileListIterator(main.bucketChoiceCombo.getValue(), "", Values.BUCKET_LIST_LIMIT_SIZE, "");
214+
String bucket = main.bucketChoiceCombo.getValue();
215+
BucketManager.FileListIterator iterator = QiniuApplication.bucketManager.createFileListIterator(bucket, "",
216+
Values.BUCKET_LIST_LIMIT_SIZE, "");
216217
ArrayList<FileInfo> files = new ArrayList<FileInfo>();
217-
logger.info("get file list of bucket");
218+
logger.info("get file list of bucket: " + bucket);
218219
// 处理获取的file list结果
219220
while (iterator.hasNext()) {
220221
com.qiniu.storage.model.FileInfo[] items = iterator.next();

src/main/java/com/zhazhapan/qiniu/controller/MainWindowController.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.apache.log4j.Logger;
1717

1818
import com.qiniu.common.QiniuException;
19+
import com.zhazhapan.qiniu.Downloader;
1920
import com.zhazhapan.qiniu.FileExecutor;
2021
import com.zhazhapan.qiniu.QiManager;
2122
import com.zhazhapan.qiniu.QiniuApplication;
@@ -189,7 +190,7 @@ private void initialize() {
189190
});
190191
// 超链接添加监听
191192
toCsdnBlog.setOnAction(e -> Utils.openLink("http://csdn.zhazhapan.com"));
192-
toHexoBlog.setOnAction(e -> Utils.openLink("http://zhazhapan.com"));
193+
toHexoBlog.setOnAction(e -> Utils.openLink("http://hexo.zhazhapan.com"));
193194
toGithubSource.setOnAction(e -> Utils.openLink("https://github.com/zhazhapan/qiniu"));
194195
String introPage = "http://zhazhapan.com/2017/10/15/%E4%B8%83%E7%89%9B%E4%BA%91%E2%80"
195196
+ "%94%E2%80%94%E5%AF%B9%E8%B1%A1%E5%AD%98%E5%82%A8%E7%AE%A1%E7%90%86%E5%B7%A5"
@@ -198,6 +199,14 @@ private void initialize() {
198199
toIntro1.setOnAction(e -> Utils.openLink("http://blog.csdn.net/qq_26954773/article/details/78245100"));
199200
}
200201

202+
/**
203+
* 通过链接下载其他的网络文件
204+
*/
205+
public void downloadFromURL() {
206+
String url = Dialogs.showInputDialog(null, Values.DOWNLOAD_URL, "http://example.com");
207+
new Downloader().downloadFromNet(url);
208+
}
209+
201210
/**
202211
* 用浏览器打开文件
203212
*/

src/main/java/com/zhazhapan/qiniu/modules/constant/Values.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,6 @@ public class Values {
100100
public static final String DOWNLOAD_FILE_ERROR = "下载文件错误";
101101

102102
public static final String OPEN_LINK_ERROR = "打开链接失败";
103+
104+
public static final String DOWNLOAD_URL = "下载链接";
103105
}

src/main/java/com/zhazhapan/qiniu/util/Checker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
*/
1313
public class Checker {
1414

15-
public static final Pattern HYPER_LINK_PATTERN = Pattern.compile("^(https*://)?([a-z0-9]+\\.)+[a-z0-9]+(/[^\\s])*$",
16-
Pattern.CASE_INSENSITIVE);
15+
public static final Pattern HYPER_LINK_PATTERN = Pattern
16+
.compile("^(https*://)?([a-z0-9]+\\.)+[a-z0-9]+(/[^\\s]*)*$", Pattern.CASE_INSENSITIVE);
1717

1818
public static final Pattern NUMBER_PATTERN = Pattern.compile("^[0-9]+$");
1919

src/main/java/com/zhazhapan/qiniu/view/Dialogs.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.zhazhapan.qiniu.config.ConfigLoader;
1515
import com.zhazhapan.qiniu.controller.MainWindowController;
1616
import com.zhazhapan.qiniu.modules.constant.Values;
17+
import com.zhazhapan.qiniu.util.Checker;
1718
import com.zhazhapan.qiniu.util.Utils;
1819

1920
import javafx.application.Platform;
@@ -177,7 +178,10 @@ public void showBucketAddableDialog() {
177178

178179
// 监听文本框的输入状态
179180
bucket.textProperty().addListener((observable, oldValue, newValue) -> {
180-
okButton.setDisable(newValue.trim().isEmpty());
181+
okButton.setDisable(newValue.trim().isEmpty() || url.getText().isEmpty());
182+
});
183+
url.textProperty().addListener((observable, oldValue, newValue) -> {
184+
okButton.setDisable(newValue.trim().isEmpty() || bucket.getText().isEmpty());
181185
});
182186

183187
dialog.getDialogPane().setContent(grid);
@@ -186,7 +190,8 @@ public void showBucketAddableDialog() {
186190

187191
dialog.setResultConverter(dialogButton -> {
188192
if (dialogButton == ok) {
189-
return new String[] { bucket.getText(), zone.getValue() + " " + url.getText() };
193+
return new String[] { bucket.getText(),
194+
zone.getValue() + " " + (Checker.isHyperLink(url.getText()) ? url.getText() : "example.com") };
190195
}
191196
return null;
192197
});

src/main/java/com/zhazhapan/qiniu/view/MainWindow.fxml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@
193193
<Insets top="10.0" />
194194
</VBox.margin>
195195
</Button>
196+
<Button mnemonicParsing="false" onAction="#downloadFromURL" text="链接下载">
197+
<VBox.margin>
198+
<Insets top="10.0" />
199+
</VBox.margin>
200+
</Button>
196201
</children>
197202
</VBox>
198203
</children>
@@ -223,6 +228,14 @@
223228
<children>
224229
<VBox prefHeight="520.0" prefWidth="593.0" GridPane.columnIndex="1" GridPane.rowIndex="1" GridPane.rowSpan="2">
225230
<children>
231+
<Label text="当前版本: v1.0.1">
232+
<font>
233+
<Font size="20.0" />
234+
</font>
235+
<VBox.margin>
236+
<Insets top="10.0" />
237+
</VBox.margin>
238+
</Label>
226239
<HBox prefHeight="47.0" prefWidth="553.0">
227240
<children>
228241
<Label text="QQ: ">
@@ -233,7 +246,7 @@
233246
<Insets top="10.0" />
234247
</HBox.margin>
235248
</Label>
236-
<TextField editable="false" style="-fx-background-color: transparenttransparent;" text="735817834">
249+
<TextField editable="false" style="-fx-background-color: transparent;" text="735817834">
237250
<HBox.margin>
238251
<Insets top="3.0" />
239252
</HBox.margin>
@@ -279,7 +292,7 @@
279292
<Insets top="10.0" />
280293
</HBox.margin>
281294
</Label>
282-
<Hyperlink fx:id="toHexoBlog" text="http://zhazhapan.com" underline="true">
295+
<Hyperlink fx:id="toHexoBlog" text="http://hexo.zhazhapan.com" underline="true">
283296
<font>
284297
<Font size="20.0" />
285298
</font>
@@ -351,15 +364,15 @@
351364
<Insets top="10.0" />
352365
</HBox.margin>
353366
</Label>
354-
<TextField editable="false" prefHeight="40.0" prefWidth="247.0" style="-fx-background-color: transparenttransparent;" text="tao@zhazhapan.com">
367+
<TextField editable="false" prefHeight="40.0" prefWidth="247.0" style="-fx-background-color: transparent;" text="tao@zhazhapan.com">
355368
<font>
356369
<Font size="20.0" />
357370
</font>
358371
<HBox.margin>
359372
<Insets top="3.0" />
360373
</HBox.margin>
361374
</TextField>
362-
<TextField editable="false" prefHeight="40.0" prefWidth="301.0" style="-fx-background-color: transparenttransparent;" text="panther.pantao@gmail.com">
375+
<TextField editable="false" prefHeight="40.0" prefWidth="301.0" style="-fx-background-color: transparent;" text="panther.pantao@gmail.com">
363376
<font>
364377
<Font size="20.0" />
365378
</font>

src/test/java/com/zhazhapan/qiniu/RegexpTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public void testHyperlink() {
3030
System.out.println(Checker.isHyperLink("http://portal.qiniu.com/bucket/zhazhapan/resource"));
3131
System.out.println(Checker.isHyperLink("portal.qiniu.com/bucket/zhazhapan/resource"));
3232
System.out.println(Checker.isHyperLink("oxns0wnsc.bkt.clouddn.com"));
33-
System.out.println(Checker.isHyperLink("http://portal"));
33+
System.out.println(Checker.isHyperLink("hhttp://portal"));
34+
System.out.println(Checker.isHyperLink("https://cn.wordpress.org/wordpress-4.8.1-zh_CN.zip"));
3435
}
3536
}

0 commit comments

Comments
 (0)