From 719a27850007cedf3e1ded0ff3915d7728678132 Mon Sep 17 00:00:00 2001 From: Max Krieger Date: Sun, 5 Feb 2023 16:12:11 -0800 Subject: [PATCH] patch: show errors for drive backup --- android/Gemfile.lock | 40 +++++++++--------- ios/Gemfile.lock | 41 ++++++++++--------- ios/fastlane/metadata/en-US/release_notes.txt | 3 +- lib/repositories/drive_backup.dart | 15 ++++++- lib/state/outline_state.dart | 2 +- pubspec.yaml | 2 +- 6 files changed, 58 insertions(+), 45 deletions(-) diff --git a/android/Gemfile.lock b/android/Gemfile.lock index 375ca0f..7efd363 100644 --- a/android/Gemfile.lock +++ b/android/Gemfile.lock @@ -8,17 +8,17 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.640.0) - aws-sdk-core (3.158.0) + aws-partitions (1.670.0) + aws-sdk-core (3.168.3) aws-eventstream (~> 1, >= 1.0.2) - aws-partitions (~> 1, >= 1.525.0) - aws-sigv4 (~> 1.1) + aws-partitions (~> 1, >= 1.651.0) + aws-sigv4 (~> 1.5) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.58.0) - aws-sdk-core (~> 3, >= 3.127.0) + aws-sdk-kms (1.60.0) + aws-sdk-core (~> 3, >= 3.165.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.114.0) - aws-sdk-core (~> 3, >= 3.127.0) + aws-sdk-s3 (1.117.2) + aws-sdk-core (~> 3, >= 3.165.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) aws-sigv4 (1.5.2) @@ -36,7 +36,7 @@ GEM unf (>= 0.0.5, < 1.0.0) dotenv (2.8.1) emoji_regex (3.2.3) - excon (0.93.0) + excon (0.94.0) faraday (1.10.2) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) @@ -66,7 +66,7 @@ GEM faraday_middleware (1.2.0) faraday (~> 1.0) fastimage (2.2.6) - fastlane (2.210.1) + fastlane (2.211.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.8, < 3.0.0) artifactory (~> 3.0) @@ -106,9 +106,9 @@ GEM xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3) gh_inspector (1.1.3) - google-apis-androidpublisher_v3 (0.28.0) - google-apis-core (>= 0.9.0, < 2.a) - google-apis-core (0.9.0) + google-apis-androidpublisher_v3 (0.31.0) + google-apis-core (>= 0.9.1, < 2.a) + google-apis-core (0.9.1) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.16.2, < 2.a) httpclient (>= 2.8.1, < 3.a) @@ -117,10 +117,10 @@ GEM retriable (>= 2.0, < 4.a) rexml webrick - google-apis-iamcredentials_v1 (0.15.0) - google-apis-core (>= 0.9.0, < 2.a) - google-apis-playcustomapp_v1 (0.11.0) - google-apis-core (>= 0.9.0, < 2.a) + google-apis-iamcredentials_v1 (0.16.0) + google-apis-core (>= 0.9.1, < 2.a) + google-apis-playcustomapp_v1 (0.12.0) + google-apis-core (>= 0.9.1, < 2.a) google-apis-storage_v1 (0.19.0) google-apis-core (>= 0.9.0, < 2.a) google-cloud-core (1.6.0) @@ -129,7 +129,7 @@ GEM google-cloud-env (1.6.0) faraday (>= 0.17.3, < 3.0) google-cloud-errors (1.3.0) - google-cloud-storage (1.43.0) + google-cloud-storage (1.44.0) addressable (~> 2.8) digest-crc (~> 0.4) google-apis-iamcredentials_v1 (~> 0.1) @@ -137,7 +137,7 @@ GEM google-cloud-core (~> 1.6) googleauth (>= 0.16.2, < 2.a) mini_mime (~> 1.0) - googleauth (1.2.0) + googleauth (1.3.0) faraday (>= 0.17.3, < 3.a) jwt (>= 1.4, < 3.0) memoist (~> 0.16) @@ -148,7 +148,7 @@ GEM http-cookie (1.0.5) domain_name (~> 0.5) httpclient (2.8.3) - jmespath (1.6.1) + jmespath (1.6.2) json (2.6.2) jwt (2.5.0) memoist (0.16.2) diff --git a/ios/Gemfile.lock b/ios/Gemfile.lock index 19c2ea1..7efd363 100644 --- a/ios/Gemfile.lock +++ b/ios/Gemfile.lock @@ -8,17 +8,17 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.640.0) - aws-sdk-core (3.158.0) + aws-partitions (1.670.0) + aws-sdk-core (3.168.3) aws-eventstream (~> 1, >= 1.0.2) - aws-partitions (~> 1, >= 1.525.0) - aws-sigv4 (~> 1.1) + aws-partitions (~> 1, >= 1.651.0) + aws-sigv4 (~> 1.5) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.58.0) - aws-sdk-core (~> 3, >= 3.127.0) + aws-sdk-kms (1.60.0) + aws-sdk-core (~> 3, >= 3.165.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.114.0) - aws-sdk-core (~> 3, >= 3.127.0) + aws-sdk-s3 (1.117.2) + aws-sdk-core (~> 3, >= 3.165.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) aws-sigv4 (1.5.2) @@ -36,7 +36,7 @@ GEM unf (>= 0.0.5, < 1.0.0) dotenv (2.8.1) emoji_regex (3.2.3) - excon (0.93.0) + excon (0.94.0) faraday (1.10.2) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) @@ -66,7 +66,7 @@ GEM faraday_middleware (1.2.0) faraday (~> 1.0) fastimage (2.2.6) - fastlane (2.210.1) + fastlane (2.211.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.8, < 3.0.0) artifactory (~> 3.0) @@ -106,9 +106,9 @@ GEM xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3) gh_inspector (1.1.3) - google-apis-androidpublisher_v3 (0.28.0) - google-apis-core (>= 0.9.0, < 2.a) - google-apis-core (0.9.0) + google-apis-androidpublisher_v3 (0.31.0) + google-apis-core (>= 0.9.1, < 2.a) + google-apis-core (0.9.1) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.16.2, < 2.a) httpclient (>= 2.8.1, < 3.a) @@ -117,10 +117,10 @@ GEM retriable (>= 2.0, < 4.a) rexml webrick - google-apis-iamcredentials_v1 (0.15.0) - google-apis-core (>= 0.9.0, < 2.a) - google-apis-playcustomapp_v1 (0.11.0) - google-apis-core (>= 0.9.0, < 2.a) + google-apis-iamcredentials_v1 (0.16.0) + google-apis-core (>= 0.9.1, < 2.a) + google-apis-playcustomapp_v1 (0.12.0) + google-apis-core (>= 0.9.1, < 2.a) google-apis-storage_v1 (0.19.0) google-apis-core (>= 0.9.0, < 2.a) google-cloud-core (1.6.0) @@ -129,7 +129,7 @@ GEM google-cloud-env (1.6.0) faraday (>= 0.17.3, < 3.0) google-cloud-errors (1.3.0) - google-cloud-storage (1.43.0) + google-cloud-storage (1.44.0) addressable (~> 2.8) digest-crc (~> 0.4) google-apis-iamcredentials_v1 (~> 0.1) @@ -137,7 +137,7 @@ GEM google-cloud-core (~> 1.6) googleauth (>= 0.16.2, < 2.a) mini_mime (~> 1.0) - googleauth (1.2.0) + googleauth (1.3.0) faraday (>= 0.17.3, < 3.a) jwt (>= 1.4, < 3.0) memoist (~> 0.16) @@ -148,7 +148,7 @@ GEM http-cookie (1.0.5) domain_name (~> 0.5) httpclient (2.8.3) - jmespath (1.6.1) + jmespath (1.6.2) json (2.6.2) jwt (2.5.0) memoist (0.16.2) @@ -210,6 +210,7 @@ GEM PLATFORMS universal-darwin-21 + universal-darwin-22 x86_64-darwin-19 DEPENDENCIES diff --git a/ios/fastlane/metadata/en-US/release_notes.txt b/ios/fastlane/metadata/en-US/release_notes.txt index 7f9dfac..01b81ff 100644 --- a/ios/fastlane/metadata/en-US/release_notes.txt +++ b/ios/fastlane/metadata/en-US/release_notes.txt @@ -1,2 +1 @@ -- Don't delete all backups if there's only one left -- Provide maximum line count for text input \ No newline at end of file +- Show snackbar when uploading backup \ No newline at end of file diff --git a/lib/repositories/drive_backup.dart b/lib/repositories/drive_backup.dart index dbb9b18..1c6e302 100644 --- a/lib/repositories/drive_backup.dart +++ b/lib/repositories/drive_backup.dart @@ -3,6 +3,7 @@ import 'dart:io' as IO; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart'; import 'package:filesize/filesize.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_archive/flutter_archive.dart'; import 'package:google_sign_in/google_sign_in.dart'; import 'package:googleapis/drive/v3.dart'; @@ -12,6 +13,7 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:tuple/tuple.dart'; import '../consts.dart'; +import '../globals.dart'; GoogleSignIn googleSignIn = GoogleSignIn(scopes: [DriveApi.driveAppdataScope]); @@ -37,8 +39,12 @@ Future getDrive() async { bool backingUp = false; /// Back up if you can -Future ifShouldBackup() async { +Future tryBackup() async { final sp = await SharedPreferences.getInstance(); + + // to debug: + // sp.setInt(lastBackupKey, 0); + final lastBackup = sp.getInt(lastBackupKey); final shouldBackup = sp.getBool(driveEnabledKey) ?? false; if (shouldBackup) { @@ -60,6 +66,7 @@ Future ifShouldBackup() async { 0)) { Sentry.addBreadcrumb(Breadcrumb( message: "Initiating auto back up", timestamp: DateTime.now())); + print("Backing up"); await makeBackup(); } @@ -150,6 +157,8 @@ Future makeBackup() async { final tmpZip = IO.File( "${tmpDir.path}/voice_outliner-${DateTime.now().millisecondsSinceEpoch}.zip"); try { + snackbarKey.currentState?.showSnackBar( + const SnackBar(content: Text("Backing up to Google Drive..."))); await ZipFile.createFromDirectory( sourceDir: docsDir, zipFile: tmpZip, @@ -167,8 +176,12 @@ Future makeBackup() async { sp.setInt(lastBackupKey, DateTime.now().millisecondsSinceEpoch); Sentry.addBreadcrumb( Breadcrumb(message: "Done backing up", timestamp: DateTime.now())); + snackbarKey.currentState?.showSnackBar( + const SnackBar(content: Text("✅ Backed up"))); } catch (e, tr) { print(e); + snackbarKey.currentState?.showSnackBar( + SnackBar(content: Text("Error during backup: $e"))); Sentry.captureException(e, stackTrace: tr); } } diff --git a/lib/state/outline_state.dart b/lib/state/outline_state.dart index 3627e90..4f577d0 100644 --- a/lib/state/outline_state.dart +++ b/lib/state/outline_state.dart @@ -115,7 +115,7 @@ class OutlinesModel extends ChangeNotifier { showCompleted = prefs.getBool(showCompletedKey) ?? true; allowRetranscription = prefs.getBool(allowRetranscriptionKey) ?? false; await loadOutlines(); - await ifShouldBackup(); + await tryBackup(); } } } diff --git a/pubspec.yaml b/pubspec.yaml index d7839c4..2fb792a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.26.2+106 +version: 1.26.4+108 environment: sdk: ">=2.12.0 <3.0.0"