Forráskód Böngészése

修复修改分组时报空指针的`BUG`

mxd 3 éve
szülő
commit
8e0d66cd3b

+ 3 - 2
magic-api/src/main/java/org/ssssssss/magicapi/adapter/resource/DatabaseResource.java

@@ -119,10 +119,11 @@ public class DatabaseResource extends KeyValueResource {
 
 	@Override
 	public Set<String> keys() {
+		String prefix = isDirectory() ? this.path : (this.path + separator);
 		if(!cachedContent.isEmpty()){
-			return cachedContent.keySet().stream().filter(it -> it.startsWith(this.path) && !it.equals(this.path)).collect(Collectors.toSet());
+			return cachedContent.keySet().stream().filter(it -> it.startsWith(prefix)).collect(Collectors.toSet());
 		}
-		String sql = String.format("select file_path from %s where file_path like '%s%%'", tableName, isDirectory() ? this.path : (this.path + separator));
+		String sql = String.format("select file_path from %s where file_path like '%s%%'", tableName, prefix);
 		return new HashSet<>(template.queryForList(sql, String.class));
 	}