Skip to content

Commit 2989b9a

Browse files
author
吴炳亨
authored
Merge pull request #292 from NigelWu95/dev
add single check by key to avoid dangerous process for whole bucket.
2 parents 9eabc3a + 88c2ce2 commit 2989b9a

File tree

5 files changed

+32
-20
lines changed

5 files changed

+32
-20
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=8.3.14
1+
version=8.3.15
22

33
package_no_test:
44
mvn package -Dmaven.test.skip=true
@@ -18,6 +18,6 @@ clean:
1818
mvn clean
1919

2020
build:
21-
mvn package -Dmaven.test.skip=true
2221
[ -d ~/.qsuits ] || mkdir ~/.qsuits
23-
cp target/qsuits-$(version)-jar-with-dependencies.jar ~/.qsuits/qsuits-$(version).jar
22+
[ -f target/qsuits-$(version)-jar-with-dependencies.jar ] || mvn package -Dmaven.test.skip=true
23+
[ -f ~/.qsuits/qsuits-$(version).jar ] || cp target/qsuits-$(version)-jar-with-dependencies.jar ~/.qsuits/qsuits-$(version).jar

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.qiniu</groupId>
88
<artifactId>qsuits</artifactId>
9-
<version>8.3.14</version>
9+
<version>8.3.15</version>
1010
<name>qsuits</name>
1111
<description>qiniu-suits is a efficient tools for qiniu api implemented by java8.</description>
1212
<url>https://github.com/NigelWu95/qiniu-suits-java</url>

src/main/java/com/qiniu/entry/CommonParams.java

+19-14
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,32 @@ public CommonParams(Map<String, String> paramsMap) throws Exception {
236236
mapLine = new HashMap<>();
237237
}
238238
switch (process) {
239+
case "delete":
240+
case "status":
241+
case "lifecycle":
242+
if (!fromLine) mapLine.put("key", entryParam.getValue("key", entryParam.getParamsMap().containsKey("key") ? "" : null));
243+
break;
239244
case "copy":
240245
case "move":
241246
case "rename":
242247
if (!fromLine) mapLine.put("key", entryParam.getValue("key", entryParam.getParamsMap().containsKey("key") ? "" : null));
243248
indexMap.put("toKey", "toKey");
244249
mapLine.put("toKey", entryParam.getValue("to-key", entryParam.getParamsMap().containsKey("to-key") ? "" : null));
245250
break;
251+
case "stat":
252+
if (!fromLine) mapLine.put("key", entryParam.getValue("key", entryParam.getParamsMap().containsKey("key") ? "" : null));
253+
saveFormat = entryParam.getValue("save-format", "tab").trim();
254+
ParamsUtils.checked(saveFormat, "save-format", "(csv|tab|json)");
255+
setSaveSeparator();
256+
break;
257+
case "mime":
258+
if (!fromLine) mapLine.put("key", entryParam.getValue("key", entryParam.getParamsMap().containsKey("key") ? "" : null));
259+
String mime = entryParam.getValue("mime", "").trim();
260+
if (!"".equals(mime)) {
261+
indexMap.put("mime", "mime");
262+
mapLine.put("mime", mime);
263+
}
264+
break;
246265
case "download":
247266
case "fetch":
248267
case "asyncfetch":
@@ -298,12 +317,6 @@ public CommonParams(Map<String, String> paramsMap) throws Exception {
298317
mapLine.put("id", id);
299318
}
300319
break;
301-
case "stat":
302-
if (!fromLine) mapLine.put("key", entryParam.getValue("key"));
303-
saveFormat = entryParam.getValue("save-format", "tab").trim();
304-
ParamsUtils.checked(saveFormat, "save-format", "(csv|tab|json)");
305-
setSaveSeparator();
306-
break;
307320
case "qupload":
308321
String key = entryParam.getValue("key", entryParam.getParamsMap().containsKey("key") ? "" : null);
309322
if (!fromLine) mapLine.put("key", key);
@@ -315,14 +328,6 @@ public CommonParams(Map<String, String> paramsMap) throws Exception {
315328
throw new IOException("filepath and key shouldn't all be empty, file must be found with them.");
316329
}
317330
break;
318-
case "mime":
319-
if (!fromLine) mapLine.put("key", entryParam.getValue("key"));
320-
String mime = entryParam.getValue("mime", "").trim();
321-
if (!"".equals(mime)) {
322-
indexMap.put("mime", "mime");
323-
mapLine.put("mime", mime);
324-
}
325-
break;
326331
default: if (!fromLine) mapLine.put("key", entryParam.getValue("key"));
327332
break;
328333
}

src/main/java/com/qiniu/entry/EntryMain.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public static void main(String[] args) throws Exception {
6565
}
6666
if (paramsMap.containsKey("verify")) processVerify = Boolean.parseBoolean(paramsMap.get("verify"));
6767
boolean single = paramsMap.containsKey("single") && Boolean.parseBoolean(paramsMap.get("single"));
68+
if (!single && paramsMap.containsKey("key") && !paramsMap.containsKey("path")) single = true;
6869
boolean interactive = paramsMap.containsKey("interactive") && Boolean.parseBoolean(paramsMap.get("interactive"));
6970
CommonParams commonParams = single ? new CommonParams(paramsMap) : new CommonParams(entryParam);
7071
QSuitsEntry qSuitsEntry = new QSuitsEntry(entryParam, commonParams);
@@ -74,7 +75,13 @@ public static void main(String[] args) throws Exception {
7475
String process = processor.getProcessName();
7576
if (processor.getNextProcessor() != null) process = processor.getNextProcessor().getProcessName();
7677
if (ProcessUtils.isDangerous(process)) {
77-
System.out.println("your last process is " + process + ", are you sure? (y/n): ");
78+
if (single) {
79+
System.out.println("your process is " + process + ", are you sure? (y/n): ");
80+
} else {
81+
String path = paramsMap.get("path");
82+
if (path == null || "".equals(path)) path = "qiniu://" + paramsMap.get("bucket");
83+
System.out.println("your last process is " + process + " for " + path + ", are you sure? (y/n): ");
84+
}
7885
Scanner scanner = new Scanner(System.in);
7986
String an = scanner.next();
8087
if (!an.equalsIgnoreCase("y") && !an.equalsIgnoreCase("yes")) {

version.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=8.3.14
1+
version=8.3.15

0 commit comments

Comments
 (0)