mirror of
https://gitee.com/blossom-editor/blossom.git
synced 2025-12-07 09:18:32 +08:00
fix: 图片重复上传时不会覆盖原图的问题
This commit is contained in:
parent
0892605211
commit
4b68eaa3e4
@ -178,7 +178,6 @@ public class PictureService extends ServiceImpl<PictureMapper, PictureEntity> {
|
|||||||
|
|
||||||
PictureEntity originPic;
|
PictureEntity originPic;
|
||||||
if ((originPic = baseMapper.selectByPathName(pic.getPathName())) != null) {
|
if ((originPic = baseMapper.selectByPathName(pic.getPathName())) != null) {
|
||||||
|
|
||||||
// 如果允许重复上传, 则修改大小
|
// 如果允许重复上传, 则修改大小
|
||||||
if (repeatUpload) {
|
if (repeatUpload) {
|
||||||
PictureEntity upd = new PictureEntity();
|
PictureEntity upd = new PictureEntity();
|
||||||
@ -187,12 +186,13 @@ public class PictureService extends ServiceImpl<PictureMapper, PictureEntity> {
|
|||||||
upd.setCreTime(new Date());
|
upd.setCreTime(new Date());
|
||||||
baseMapper.updById(upd);
|
baseMapper.updById(upd);
|
||||||
pic.setId(originPic.getId());
|
pic.setId(originPic.getId());
|
||||||
return pic;
|
} else {
|
||||||
}
|
|
||||||
throw new XzException400HTTP("图片[" + pic.getPathName() + "]已存在, 请重命名文件或选择其他路径!");
|
throw new XzException400HTTP("图片[" + pic.getPathName() + "]已存在, 请重命名文件或选择其他路径!");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
baseMapper.insert(pic);
|
baseMapper.insert(pic);
|
||||||
|
}
|
||||||
|
|
||||||
// 入库后进行文件上传操作
|
// 入库后进行文件上传操作
|
||||||
try (InputStream inputStream = file.getInputStream()) {
|
try (InputStream inputStream = file.getInputStream()) {
|
||||||
osManager.put(pic.getPathName(), inputStream);
|
osManager.put(pic.getPathName(), inputStream);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user