diff --git a/lib/utils/file_sync_util.dart b/lib/utils/file_sync_util.dart index ef4e397b7..b720d5ea5 100644 --- a/lib/utils/file_sync_util.dart +++ b/lib/utils/file_sync_util.dart @@ -7,6 +7,7 @@ import 'package:photos/models/file.dart'; final _logger = Logger("FileSyncUtil"); final ignoreSizeConstraint = SizeConstraint(ignoreSize: true); +final assetFetchPageSize = 2000; Future> getDeviceFiles( int fromTime, int toTime, Computer computer) async { final pathEntities = await _getGalleryList(fromTime, toTime); @@ -41,8 +42,7 @@ Future> getAllLocalAssets() async { ); final List 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> _computeFiles(AssetPathEntity pathEntity, int fromTime, List files, Computer computer) async { final args = Map(); 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> _getAllAssetLists(AssetPathEntity pathEntity) async { + List result = []; + int currentPage = 0; + List currentPageResult = []; + do { + currentPageResult = await pathEntity.getAssetListPaged( + page: currentPage, size: assetFetchPageSize); + result.addAll(currentPageResult); + currentPage = currentPage + 1; + } while (currentPageResult.length >= assetFetchPageSize); + return result; +} + Future> _getFiles(Map args) async { final pathEntity = args["pathEntity"]; final assetList = args["assetList"];