diff --git a/app/lib/ui/flow/home/local/local_media_screen_view_model.dart b/app/lib/ui/flow/home/local/local_media_screen_view_model.dart index 537fe59..ea58502 100644 --- a/app/lib/ui/flow/home/local/local_media_screen_view_model.dart +++ b/app/lib/ui/flow/home/local/local_media_screen_view_model.dart @@ -92,6 +92,7 @@ class LocalMediasViewStateNotifier extends StateNotifier { state = state.copyWith(uploadingMedias: state.selectedMedias, error: null); final folderId = await _googleDriveService.getBackupFolderId(); + for (final media in state.selectedMedias) { await _googleDriveService.uploadInGoogleDrive( media: media, folderID: folderId!); diff --git a/data/lib/services/google_drive_service.dart b/data/lib/services/google_drive_service.dart index f13fdcc..2b542b5 100644 --- a/data/lib/services/google_drive_service.dart +++ b/data/lib/services/google_drive_service.dart @@ -33,10 +33,10 @@ class GoogleDriveService { final driveApi = await _getGoogleDriveAPI(); final response = await driveApi.files.list( - q: "name='$_backUpFolderName' and description='$_backUpFolderDescription' and mimeType='application/vnd.google-apps.folder'", + q: "name='$_backUpFolderName' and mimeType='application/vnd.google-apps.folder'", ); - if (response.files?.isNotEmpty ?? false) { + if (response.files?.isNotEmpty ?? false || response.files?.first.trashed == false) { return response.files?.first.id; } else { final folder = drive.File( @@ -60,7 +60,7 @@ class GoogleDriveService { final file = drive.File( name: media.name ?? localFile.path.split('/').last, - id: media.id, + description: media.path, parents: [folderID], ); await driveApi.files.create( @@ -68,6 +68,7 @@ class GoogleDriveService { uploadMedia: drive.Media(localFile.openRead(), localFile.lengthSync()), ); } catch (error) { + print(error); throw AppError.fromError(error); } }