mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-04 03:27:09 -05:00 
			
		
		
		
	feat(mobile): upload image assets before videos (#3958)
* feat(mobile): upload image assets before videos (#3872) * feat(mobile): upload image assets before videos * mobile: sort by creation date before uploading assets * feat(mobile): upload newest assets first for foreground upload * feat(mobile): upload images before videos only for background backup
This commit is contained in:
		
							parent
							
								
									74d34b4f6c
								
							
						
					
					
						commit
						73ad0d468f
					
				@ -459,6 +459,7 @@ class BackgroundService {
 | 
			
		||||
      notifySingleProgress ? _onProgress : (sent, total) {},
 | 
			
		||||
      notifySingleProgress ? _onSetCurrentBackupAsset : (asset) {},
 | 
			
		||||
      _onBackupError,
 | 
			
		||||
      sortAssets: true,
 | 
			
		||||
    );
 | 
			
		||||
    if (!ok && !_cancellationToken!.isCancelled) {
 | 
			
		||||
      _showErrorNotification(
 | 
			
		||||
 | 
			
		||||
@ -202,8 +202,9 @@ class BackupService {
 | 
			
		||||
    Function(String, String, bool) uploadSuccessCb,
 | 
			
		||||
    Function(int, int) uploadProgressCb,
 | 
			
		||||
    Function(CurrentUploadAsset) setCurrentUploadAssetCb,
 | 
			
		||||
    Function(ErrorUploadAsset) errorCb,
 | 
			
		||||
  ) async {
 | 
			
		||||
    Function(ErrorUploadAsset) errorCb, {
 | 
			
		||||
    bool sortAssets = false,
 | 
			
		||||
  }) async {
 | 
			
		||||
    if (Platform.isAndroid &&
 | 
			
		||||
        !(await Permission.accessMediaLocation.status).isGranted) {
 | 
			
		||||
      // double check that permission is granted here, to guard against
 | 
			
		||||
@ -221,7 +222,19 @@ class BackupService {
 | 
			
		||||
    // DON'T KNOW WHY BUT THIS HELPS BACKGROUND BACKUP TO WORK ON IOS
 | 
			
		||||
    await PhotoManager.requestPermissionExtend();
 | 
			
		||||
 | 
			
		||||
    for (var entity in assetList) {
 | 
			
		||||
    List<AssetEntity> assetsToUpload = sortAssets
 | 
			
		||||
        // Upload images before video assets
 | 
			
		||||
        // these are further sorted by using their creation date
 | 
			
		||||
        ? assetList.sorted(
 | 
			
		||||
            (a, b) {
 | 
			
		||||
              final cmp = a.typeInt - b.typeInt;
 | 
			
		||||
              if (cmp != 0) return cmp;
 | 
			
		||||
              return a.createDateTime.compareTo(b.createDateTime);
 | 
			
		||||
            },
 | 
			
		||||
          )
 | 
			
		||||
        : assetList.toList();
 | 
			
		||||
 | 
			
		||||
    for (var entity in assetsToUpload) {
 | 
			
		||||
      try {
 | 
			
		||||
        if (entity.type == AssetType.video) {
 | 
			
		||||
          file = await entity.originFile;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user