diff --git a/lib/services/sync_service.dart b/lib/services/sync_service.dart index 61db55168..2a777566d 100644 --- a/lib/services/sync_service.dart +++ b/lib/services/sync_service.dart @@ -158,32 +158,13 @@ class SyncService { if (!Configuration.instance.hasConfiguredAccount()) { return Future.error("Account not configured yet"); } + // TODO: Verify flow starting here await CollectionsService.instance.sync(); - await _persistFilesDiff(); await _persistEncryptedFilesDiff(); await _uploadDiff(); await _deletePhotosOnServer(); } - Future _persistFilesDiff() async { - final diff = await _downloader.getFilesDiff(_getSyncTime(), _diffLimit); - if (diff != null && diff.isNotEmpty) { - await _storeDiff(diff, _syncTimeKey); - FileRepository.instance.reloadFiles(); - if (diff.length == _diffLimit) { - return await _persistFilesDiff(); - } - } - } - - int _getSyncTime() { - var syncTime = _prefs.getInt(_syncTimeKey); - if (syncTime == null) { - syncTime = 0; - } - return syncTime; - } - Future _persistEncryptedFilesDiff() async { final diff = await _downloader.getEncryptedFilesDiff( _getEncryptedFilesSyncTime(), _diffLimit); diff --git a/lib/utils/file_downloader.dart b/lib/utils/file_downloader.dart index 46585beb0..1f63b9838 100644 --- a/lib/utils/file_downloader.dart +++ b/lib/utils/file_downloader.dart @@ -18,8 +18,9 @@ class DiffFetcher { return _dio .get( Configuration.instance.getHttpEndpoint() + "/files/diff", + options: Options( + headers: {"X-Auth-Token": Configuration.instance.getToken()}), queryParameters: { - "token": Configuration.instance.getToken(), "sinceTime": lastSyncTime, "limit": limit, }, @@ -60,25 +61,4 @@ class DiffFetcher { return files; }); } - - Future> getFilesDiff(int lastSyncTime, int limit) async { - Response response = await _dio.get( - Configuration.instance.getHttpEndpoint() + "/files/diff", - options: - Options(headers: {"X-Auth-Token": Configuration.instance.getToken()}), - queryParameters: { - "sinceTime": lastSyncTime, - "limit": limit, - }, - ).catchError((e) => _logger.severe(e)); - if (response != null) { - Bus.instance.fire(RemoteSyncEvent(true)); - return (response.data["diff"] as List) - .map((file) => new File.fromJson(file)) - .toList(); - } else { - Bus.instance.fire(RemoteSyncEvent(false)); - return null; - } - } }