本文整理汇总了Java中com.liulishuo.filedownloader.util.FileDownloadHelper.inspectAndInflowDownloaded方法的典型用法代码示例。如果您正苦于以下问题:Java FileDownloadHelper.inspectAndInflowDownloaded方法的具体用法?Java FileDownloadHelper.inspectAndInflowDownloaded怎么用?Java FileDownloadHelper.inspectAndInflowDownloaded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liulishuo.filedownloader.util.FileDownloadHelper
的用法示例。
在下文中一共展示了FileDownloadHelper.inspectAndInflowDownloaded方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkupBeforeFetch
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入方法依赖的package包/类
private void checkupBeforeFetch() throws RetryDirectly, DiscardSafely {
final int id = model.getId();
if (model.isPathAsDirectory()) {
// this scope for caring about the case of there is another task is provided
// the same path to store file and the same url.
final String targetFilePath = model.getTargetFilePath();
// get the ID after got the filename.
final int fileCaseId = FileDownloadUtils.generateId(model.getUrl(),
targetFilePath);
// whether the file with the filename has been existed.
if (FileDownloadHelper.inspectAndInflowDownloaded(id,
targetFilePath, isForceReDownload, false)) {
database.remove(id);
database.removeConnections(id);
throw new DiscardSafely();
}
final FileDownloadModel fileCaseModel = database.find(fileCaseId);
if (fileCaseModel != null) {
// the task with the same file name and url has been exist.
// whether the another task with the same file and url is downloading.
if (FileDownloadHelper.inspectAndInflowDownloading(id, fileCaseModel,
threadPoolMonitor, false)) {
//it has been post to upper layer the 'warn' message, so the current
// task no need to continue download.
database.remove(id);
database.removeConnections(id);
throw new DiscardSafely();
}
final List<ConnectionModel> connectionModelList = database.findConnectionModel(fileCaseId);
// the another task with the same file name and url is paused
database.remove(fileCaseId);
database.removeConnections(fileCaseId);
FileDownloadUtils.deleteTargetFile(model.getTargetFilePath());
if (FileDownloadUtils.isBreakpointAvailable(fileCaseId, fileCaseModel)) {
model.setSoFar(fileCaseModel.getSoFar());
model.setTotal(fileCaseModel.getTotal());
model.setETag(fileCaseModel.getETag());
model.setConnectionCount(fileCaseModel.getConnectionCount());
database.update(model);
// re connect to resume from breakpoint.
if (connectionModelList != null) {
for (ConnectionModel connectionModel : connectionModelList) {
connectionModel.setId(id);
database.insertConnectionModel(connectionModel);
}
}
// retry
throw new RetryDirectly();
}
}
// whether there is an another running task with the same target-file-path.
if (FileDownloadHelper.inspectAndInflowConflictPath(id, model.getSoFar(),
model.getTempFilePath(),
targetFilePath,
threadPoolMonitor)) {
database.remove(id);
database.removeConnections(id);
throw new DiscardSafely();
}
}
}
示例2: checkupBeforeFetch
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入方法依赖的package包/类
private void checkupBeforeFetch() throws RetryDirectly, DiscardSafely {
final int id = model.getId();
if (model.isPathAsDirectory()) {
// this scope for caring about the case of there is another task is provided
// the same path to store file and the same url.
final String targetFilePath = model.getTargetFilePath();
// get the ID after got the filename.
final int fileCaseId = FileDownloadUtils.generateId(model.getUrl(),
targetFilePath);
// whether the file with the filename has been existed.
if (FileDownloadHelper.inspectAndInflowDownloaded(id,
targetFilePath, isForceReDownload, false)) {
database.remove(id);
database.removeConnections(id);
throw new DiscardSafely();
}
final FileDownloadModel fileCaseModel = database.find(fileCaseId);
if (fileCaseModel != null) {
// the task with the same file name and url has been exist.
// whether the another task with the same file and url is downloading.
if (FileDownloadHelper.inspectAndInflowDownloading(id, fileCaseModel,
threadPoolMonitor, false)) {
//it has been post to upper layer the 'warn' message, so the current
// task no need to continue download.
database.remove(id);
database.removeConnections(id);
throw new DiscardSafely();
}
final List<ConnectionModel> connectionModelList = database
.findConnectionModel(fileCaseId);
// the another task with the same file name and url is paused
database.remove(fileCaseId);
database.removeConnections(fileCaseId);
FileDownloadUtils.deleteTargetFile(model.getTargetFilePath());
if (FileDownloadUtils.isBreakpointAvailable(fileCaseId, fileCaseModel)) {
model.setSoFar(fileCaseModel.getSoFar());
model.setTotal(fileCaseModel.getTotal());
model.setETag(fileCaseModel.getETag());
model.setConnectionCount(fileCaseModel.getConnectionCount());
database.update(model);
// re connect to resume from breakpoint.
if (connectionModelList != null) {
for (ConnectionModel connectionModel : connectionModelList) {
connectionModel.setId(id);
database.insertConnectionModel(connectionModel);
}
}
// retry
throw new RetryDirectly();
}
}
// whether there is an another running task with the same target-file-path.
if (FileDownloadHelper.inspectAndInflowConflictPath(id, model.getSoFar(),
model.getTempFilePath(),
targetFilePath,
threadPoolMonitor)) {
database.remove(id);
database.removeConnections(id);
throw new DiscardSafely();
}
}
}