add method to fetch all assets in an assetPath
This commit is contained in:
parent
22babe31e6
commit
f5bb25f29b
1 changed files with 16 additions and 3 deletions
|
@ -7,6 +7,7 @@ import 'package:photos/models/file.dart';
|
|||
|
||||
final _logger = Logger("FileSyncUtil");
|
||||
final ignoreSizeConstraint = SizeConstraint(ignoreSize: true);
|
||||
final assetFetchPageSize = 2000;
|
||||
Future<List<File>> getDeviceFiles(
|
||||
int fromTime, int toTime, Computer computer) async {
|
||||
final pathEntities = await _getGalleryList(fromTime, toTime);
|
||||
|
@ -41,8 +42,7 @@ Future<List<LocalAsset>> getAllLocalAssets() async {
|
|||
);
|
||||
final List<LocalAsset> assets = [];
|
||||
for (final assetPath in assetPaths) {
|
||||
for (final asset
|
||||
in await assetPath.getAssetListPaged(page: 0, size: 10000)) {
|
||||
for (final asset in await _getAllAssetLists(assetPath)) {
|
||||
assets.add(LocalAsset(asset.id, assetPath.name));
|
||||
}
|
||||
}
|
||||
|
@ -134,12 +134,25 @@ Future<List<File>> _computeFiles(AssetPathEntity pathEntity, int fromTime,
|
|||
List<File> files, Computer computer) async {
|
||||
final args = Map<String, dynamic>();
|
||||
args["pathEntity"] = pathEntity;
|
||||
args["assetList"] = await pathEntity.getAssetListPaged(page: 0, size: 10000);
|
||||
args["assetList"] = await _getAllAssetLists(pathEntity);
|
||||
args["fromTime"] = fromTime;
|
||||
args["files"] = files;
|
||||
return await computer.compute(_getFiles, param: args);
|
||||
}
|
||||
|
||||
Future<List<AssetEntity>> _getAllAssetLists(AssetPathEntity pathEntity) async {
|
||||
List<AssetEntity> result = [];
|
||||
int currentPage = 0;
|
||||
List<AssetEntity> currentPageResult = [];
|
||||
do {
|
||||
currentPageResult = await pathEntity.getAssetListPaged(
|
||||
page: currentPage, size: assetFetchPageSize);
|
||||
result.addAll(currentPageResult);
|
||||
currentPage = currentPage + 1;
|
||||
} while (currentPageResult.length >= assetFetchPageSize);
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<List<File>> _getFiles(Map<String, dynamic> args) async {
|
||||
final pathEntity = args["pathEntity"];
|
||||
final assetList = args["assetList"];
|
||||
|
|
Loading…
Add table
Reference in a new issue