diff --git a/lib/sync/repository/src/google_drive.dart b/lib/sync/repository/src/google_drive.dart index 9e97553..ae8bd1e 100644 --- a/lib/sync/repository/src/google_drive.dart +++ b/lib/sync/repository/src/google_drive.dart @@ -14,10 +14,7 @@ class GoogleDrive implements SyncRepository { @override Future?> download({required String fileName}) async { final fileId = await _getFileId(fileName); - - if (fileId == null) { - throw SyncException('File does not exist.'); - } + if (fileId == null) return null; final Media media; try { @@ -26,9 +23,7 @@ class GoogleDrive implements SyncRepository { downloadOptions: DownloadOptions.fullMedia, ) as Media; } on DetailedApiRequestError catch (e) { - if (e.status == io.HttpStatus.notFound) { - throw SyncException('File does not exist.'); - } + log.e('Failed to download file', e); return null; } diff --git a/lib/sync/sync_service.dart b/lib/sync/sync_service.dart index 97aeb23..73cded1 100644 --- a/lib/sync/sync_service.dart +++ b/lib/sync/sync_service.dart @@ -78,18 +78,12 @@ class SyncService { /// /// Throws a [SyncException] if an error occurs. Future _downloadSyncData() async { - try { - final cloudSyncDataBytes = await _syncRepository.download( - fileName: kSyncDataFileName, - ); + final cloudSyncDataBytes = await _syncRepository.download( + fileName: kSyncDataFileName, + ); - if (cloudSyncDataBytes != null) { - return SyncData.fromBytes(cloudSyncDataBytes); - } - } on SyncException catch (e) { - throw SyncException( - 'Failed to download sync data from cloud service: ${e.message}', - ); + if (cloudSyncDataBytes != null) { + return SyncData.fromBytes(cloudSyncDataBytes); } return null;