laoyuyu 5 years ago
parent 27459e7d9a
commit 685f6b5525
  1. 2
      Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
  2. 2
      Aria/src/main/java/com/arialyy/aria/core/common/controller/BuilderController.java
  3. 3
      DEV_LOG.md
  4. 2
      FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDFileInfoThread.java
  5. 2
      HttpComponent/src/main/java/com/arialyy/aria/http/HttpFileInfoThread.java
  6. 133
      PublicComponent/src/main/java/com/arialyy/aria/util/FileUtil.java
  7. 2
      app/src/main/assets/aria_config.xml
  8. 1
      app/src/main/java/com/arialyy/simple/MainActivity.java
  9. 5
      app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java
  10. 7
      app/src/main/java/com/arialyy/simple/core/download/group/GroupModule.java
  11. 4
      build.gradle

@ -115,7 +115,6 @@ import java.util.concurrent.ConcurrentHashMap;
initDb(APP);
regAppLifeCallback(APP);
initAria();
amendTaskState();
}
public Context getAPP() {
@ -137,6 +136,7 @@ import java.util.concurrent.ConcurrentHashMap;
}
}
mDbWrapper = DelegateWrapper.init(context.getApplicationContext());
amendTaskState();
}
private void initAria() {

@ -30,7 +30,7 @@ public final class BuilderController extends FeatureController implements IStart
}
/**
* 添加任务
* 添加任务只添加任务不进行下载
*
* @return 正常添加返回任务id否则返回-1
*/

@ -1,6 +1,7 @@
## 开发日志
+ v_3.8.2
+ v_3.8.3
- fix bug https://github.com/AriaLyy/Aria/issues/573
- android P适配 https://github.com/AriaLyy/Aria/issues/581
+ v_3.8.1 (2019/12/22)
- 修复一个表创建失败的问题 https://github.com/AriaLyy/Aria/issues/570
- 修复一个非分块模式下导致下载失败的问题 https://github.com/AriaLyy/Aria/issues/571

@ -38,7 +38,7 @@ class FtpDFileInfoThread extends AbsFtpInfoThread<DownloadEntity, DTaskWrapper>
@Override protected void handleFile(String remotePath, FTPFile ftpFile) {
super.handleFile(remotePath, ftpFile);
if (!FileUtil.checkSDMemorySpace(mEntity.getFilePath(), ftpFile.getSize())) {
if (!FileUtil.checkMemorySpace(mEntity.getFilePath(), ftpFile.getSize())) {
mCallback.onFail(mEntity, new AriaIOException(TAG,
String.format("获取ftp文件信息失败,内存空间不足, filePath: %s", mEntity.getFilePath())),
false);

@ -125,7 +125,7 @@ public class HttpFileInfoThread implements Runnable {
}
long len = lenAdapter.handleFileLen(conn.getHeaderFields());
if (!FileUtil.checkSDMemorySpace(mEntity.getFilePath(), len)) {
if (!FileUtil.checkMemorySpace(mEntity.getFilePath(), len)) {
failDownload(new TaskException(TAG,
String.format("下载失败,内存空间不足;filePath: %s, url: %s", mEntity.getDownloadPath(),
mEntity.getUrl())), false);

@ -374,6 +374,76 @@ public class FileUtil {
}
}
/**
* 检查内存空间是否充足
*
* @param path 文件路径
* @param fileSize 下载的文件的大小
* @return true 空间足够
*/
public static boolean checkMemorySpace(String path, long fileSize) {
File temp = new File(path);
if (!temp.exists()){
if (!temp.getParentFile().exists()){
FileUtil.createDir(temp.getParentFile().getPath());
}
path = temp.getParentFile().getPath();
}
StatFs stat = new StatFs(path);
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return fileSize <= availableBlocks * blockSize;
}
/**
* 读取下载配置文件
*/
public static Properties loadConfig(File file) {
Properties properties = new Properties();
FileInputStream fis = null;
if (!file.exists()) {
createFile(file.getPath());
}
try {
fis = new FileInputStream(file);
properties.load(fis);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return properties;
}
/**
* 保存配置文件
*/
public static void saveConfig(File file, Properties properties) {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file, false);
properties.store(fos, null);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fos != null) {
fos.flush();
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 检查SD内存空间是否充足
*
@ -381,7 +451,8 @@ public class FileUtil {
* @param fileSize 文件大小
* @return {@code false} 内存空间不足{@code true}内存空间足够
*/
public static boolean checkSDMemorySpace(String filePath, long fileSize) {
@Deprecated
private static boolean checkSDMemorySpace(String filePath, long fileSize) {
List<String> dirs = FileUtil.getSDPathList(AriaConfig.getInstance().getAPP());
if (dirs == null || dirs.isEmpty()) {
return true;
@ -402,7 +473,7 @@ public class FileUtil {
* @param sdcardPath sdcard 根路径
* @return 单位为byte
*/
public static long getAvailableExternalMemorySize(String sdcardPath) {
private static long getAvailableExternalMemorySize(String sdcardPath) {
StatFs stat = new StatFs(sdcardPath);
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
@ -415,7 +486,7 @@ public class FileUtil {
* @param sdcardPath sdcard 根路径
* @return 单位为byte
*/
public static long getTotalExternalMemorySize(String sdcardPath) {
private static long getTotalExternalMemorySize(String sdcardPath) {
StatFs stat = new StatFs(sdcardPath);
long blockSize = stat.getBlockSize();
long totalBlocks = stat.getBlockCount();
@ -425,13 +496,11 @@ public class FileUtil {
/**
* 获取SD卡目录列表
*/
public static List<String> getSDPathList(Context context) {
private static List<String> getSDPathList(Context context) {
List<String> paths = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
try {
paths = getVolumeList(context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
@ -447,59 +516,11 @@ public class FileUtil {
return paths;
}
/**
* 读取下载配置文件
*/
public static Properties loadConfig(File file) {
Properties properties = new Properties();
FileInputStream fis = null;
if (!file.exists()) {
createFile(file.getPath());
}
try {
fis = new FileInputStream(file);
properties.load(fis);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return properties;
}
/**
* 保存配置文件
*/
public static void saveConfig(File file, Properties properties) {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file, false);
properties.store(fos, null);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fos != null) {
fos.flush();
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* getSDPathList
*/
private static List<String> getVolumeList(final Context context)
throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException,
throws NoSuchMethodException, InvocationTargetException,
IllegalAccessException {
List<String> pathList = new ArrayList<>();
@ -589,7 +610,7 @@ public class FileUtil {
*
* @return paths to all available SD-Cards in the system (include emulated)
*/
public static List<String> getStorageDirectories() {
private static List<String> getStorageDirectories() {
// Final set of paths
final List<String> rv = new ArrayList<>();
// Primary physical SD-CARD (not emulated)

@ -44,7 +44,7 @@
<threadNum value="3"/>
<!--设置下载队列最大任务数, 默认为2-->
<maxTaskNum value="3"/>
<maxTaskNum value="1"/>
<!--设置下载失败,重试次数,默认为10-->
<reTryNum value="5"/>

@ -29,7 +29,6 @@ import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.frame.permission.OnPermissionCallback;
import com.arialyy.frame.permission.PermissionManager;
import com.arialyy.frame.util.show.T;

@ -20,6 +20,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.StatFs;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@ -32,7 +33,6 @@ import androidx.lifecycle.ViewModelProviders;
import com.arialyy.annotations.Download;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.common.HttpOption;
import com.arialyy.aria.core.common.RequestEnum;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.listener.ISchedulers;
@ -40,16 +40,13 @@ import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.util.FileUtil;
import com.arialyy.frame.util.show.T;
import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.common.ModifyPathDialog;
import com.arialyy.simple.common.ModifyUrlDialog;
import com.arialyy.simple.databinding.ActivitySingleBinding;
import com.arialyy.simple.util.AppUtil;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@ -54,6 +54,13 @@ public class GroupModule extends BaseModule {
return names;
}
List<String> getSubName1() {
List<String> names = new ArrayList<>();
String[] str = getContext().getResources().getStringArray(R.array.group_names);
Collections.addAll(names, str);
return names;
}
List<String> getSubName2() {
List<String> taskSubFile;
taskSubFile = new ArrayList<>();

@ -44,8 +44,8 @@ task clean(type: Delete) {
}
ext {
versionCode = 381
versionName = '3.8.1'
versionCode = 383
versionName = '3.8.3_beta'
userOrg = 'arialyy'
groupId = 'com.arialyy.aria'
publishVersion = versionName

Loading…
Cancel
Save