先保存下载任务再下发节点以保留即时状态
This commit is contained in:
@@ -16,6 +16,9 @@ public interface CustomConfigurationMapper {
|
||||
// @Delete("delete from customConfiguration where parameter=#{parameter}")
|
||||
// void deleteConfiguration(CustomConfiguration configuration);
|
||||
|
||||
@Update("update customConfiguration set value=cast(value as integer)+#{amount} where parameter=#{parameter}")
|
||||
void incrementConfiguration(@Param("parameter") String parameter, @Param("amount") long amount);
|
||||
|
||||
@Select("select * from customConfiguration where parameter=#{parameter}")
|
||||
CustomConfiguration selectConfiguration(String parameter);
|
||||
}
|
||||
|
||||
@@ -93,9 +93,14 @@ public class GalleryManageService {
|
||||
} else {
|
||||
taskName = gallery.getName();
|
||||
log.info("创建任务: {} 目标分辨率:{}", link, targetResolution);
|
||||
// Persist before dispatch: the node sends its current status before its ACK.
|
||||
gallery.setDownloader(user.getId());
|
||||
gallery.set_download(true);
|
||||
galleryMapper.insertGallery(gallery);
|
||||
configurationMapper.incrementConfiguration(CustomConfiguration.WEEK_USED_AMOUNT, gallery.getFileSize());
|
||||
if (remoteService.addGalleryToQueue(gallery) != 0) {
|
||||
log.error("传送任务{}失败, 未知原因", gallery.getName());
|
||||
response.failure("任务传送失败,未知原因,尝试点击重连按钮看看");
|
||||
response.failure("任务已保存,但节点未确认接收;请刷新任务列表后重试");
|
||||
pushService.taskCreateReport(user.getUsername(), taskName, response);
|
||||
return response.toJSONString();
|
||||
}
|
||||
@@ -111,20 +116,9 @@ public class GalleryManageService {
|
||||
return response.toJSONString();
|
||||
}
|
||||
|
||||
//处理下载结果,将任务插入数据库并且更新每周用量
|
||||
if (gallery.getStatus().equals("已提交")) {
|
||||
response.success(gallery.toString());
|
||||
gallery.setDownloader(user.getId());
|
||||
gallery.set_download(true);
|
||||
galleryMapper.insertGallery(gallery);
|
||||
|
||||
long usedAmount = Long.parseLong(configurationMapper.selectConfiguration(CustomConfiguration.WEEK_USED_AMOUNT).getValue());
|
||||
usedAmount += gallery.getFileSize();
|
||||
configurationMapper.updateConfiguration(CustomConfiguration.WEEK_USED_AMOUNT, String.valueOf(usedAmount));
|
||||
} else {
|
||||
response.failure("提交失败,未知原因");
|
||||
galleryMapper.deleteGalleryByGid(gallery.getGid());
|
||||
}
|
||||
// Do not overwrite an immediate node status with the original submitted state.
|
||||
Gallery current = galleryMapper.selectGalleryByGid(gallery.getGid());
|
||||
response.success((current == null ? gallery : current).toString());
|
||||
pushService.taskCreateReport(user.getUsername(), taskName, response);
|
||||
|
||||
return response.toJSONString();
|
||||
|
||||
Reference in New Issue
Block a user