| 262 | } |
| 263 | |
| 264 | public void deleteByBackuprootid(long rootid) throws SQLException { |
| 265 | long counter = 0; |
| 266 | long timestamp = new Date().getTime() / 1000; |
| 267 | System.out.println("loading files backuprootid=" + rootid); |
| 268 | ResultSet ret = mysqlHelper.querySql("select id from tb_backfiles where backuprootid=" + rootid); |
| 269 | List<Long> tbbackfilesList = new ArrayList<>(); |
| 270 | while (ret != null && ret.next()) |
| 271 | { |
| 272 | tbbackfilesList.add(ret.getLong("id")); |
| 273 | } |
| 274 | for(long id:tbbackfilesList) |
| 275 | { |
| 276 | ResultSet subret= mysqlHelper.querySql("select id,backuptargetpath from tb_backfilehistory where backupfileid="+id); |
| 277 | if(subret!=null&&subret.next()) |
| 278 | { |
| 279 | File file=new File(subret.getString("backuptargetpath")); |
| 280 | if(file.exists()) |
| 281 | { |
| 282 | file.delete(); |
| 283 | } |
| 284 | else |
| 285 | { |
| 286 | logger.error("not found target path:"+subret.getString("backuptargetpath")); |
| 287 | } |
| 288 | mysqlHelper.exeSql("delete from tb_backfilehistory where id="+subret.getInt("id")); |
| 289 | } |
| 290 | counter++; |
| 291 | if(new Date().getTime()/1000!=timestamp) |
| 292 | { |
| 293 | timestamp=new Date().getTime()/1000; |
| 294 | System.out.println("delete progress:"+counter*100/tbbackfilesList.size()+"% "+counter+"/"+tbbackfilesList.size()); |
| 295 | } |
| 296 | } |
| 297 | mysqlHelper.exeSql("delete from tb_backfiles where backuprootid="+rootid); |
| 298 | } |
| 299 | |
| 300 | public void XCopy() |
| 301 | { |