mirror of
https://gitee.com/ssssssss-team/magic-api.git
synced 2026-06-18 11:42:35 +08:00
修复修改分组名称可能出现的空指针异常
This commit is contained in:
@@ -61,7 +61,6 @@ public class DatabaseResource extends KeyValueResource {
|
||||
|
||||
@Override
|
||||
public void readAll() {
|
||||
this.cachedContent.clear();
|
||||
String sql = String.format("select file_path, file_content from %s where file_path like '%s%%'", tableName, this.path);
|
||||
SqlRowSet sqlRowSet = template.queryForRowSet(sql);
|
||||
while (sqlRowSet.next()) {
|
||||
@@ -93,7 +92,7 @@ public class DatabaseResource extends KeyValueResource {
|
||||
|
||||
@Override
|
||||
public boolean exists() {
|
||||
if (this.cachedContent.containsKey(this.path)) {
|
||||
if (this.cachedContent.get(this.path) != null) {
|
||||
return true;
|
||||
}
|
||||
String sql = String.format("select count(*) from %s where file_path = ?", tableName);
|
||||
@@ -137,9 +136,10 @@ public class DatabaseResource extends KeyValueResource {
|
||||
|
||||
@Override
|
||||
public boolean delete() {
|
||||
String sql = String.format("delete from %s where file_path = ? or file_path like '%s%%'", tableName, isDirectory() ? this.path : this.path + separator);
|
||||
String path = isDirectory() ? this.path : this.path + separator;
|
||||
String sql = String.format("delete from %s where file_path = ? or file_path like '%s%%'", tableName, path);
|
||||
if (template.update(sql, this.path) > 0) {
|
||||
this.cachedContent.remove(this.path);
|
||||
this.cachedContent.entrySet().removeIf(entry -> entry.getKey().startsWith(path));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -31,7 +31,6 @@ public class RedisResource extends KeyValueResource {
|
||||
|
||||
@Override
|
||||
public void readAll() {
|
||||
this.cachedContent.clear();
|
||||
List<String> keys = new ArrayList<>(keys());
|
||||
List<String> values = redisTemplate.opsForValue().multiGet(keys);
|
||||
if (values != null) {
|
||||
@@ -66,7 +65,7 @@ public class RedisResource extends KeyValueResource {
|
||||
|
||||
@Override
|
||||
public boolean exists() {
|
||||
if (this.cachedContent.containsKey(this.path)) {
|
||||
if (this.cachedContent.get(this.path) != null) {
|
||||
return true;
|
||||
}
|
||||
return Boolean.TRUE.equals(this.redisTemplate.hasKey(this.path));
|
||||
|
||||
Reference in New Issue
Block a user