Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import a backup isn't working #95

Closed
MaxSchlueter opened this issue Oct 5, 2021 · 9 comments · Fixed by #114
Closed

Import a backup isn't working #95

MaxSchlueter opened this issue Oct 5, 2021 · 9 comments · Fixed by #114
Labels
bug Something isn't working

Comments

@MaxSchlueter
Copy link

Describe the bug
Importing a backup that I've previously exported to a file isn't working, the workout doesn't show up in the list.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Settings
  2. Click on "Import a backup"
  3. Selected a previously exported workout
  4. The previously exported workout doesn't show up in the list of workouts

Expected behavior
Would expect the workout to show up in the list.

Smartphone (please complete the following information):

  • Device: Google Pixel 2
  • OS: Android 11
@MaxSchlueter MaxSchlueter added the bug Something isn't working label Oct 5, 2021
@blockbasti
Copy link
Owner

Did you create the backup by exporting a workout or did you just copy the files from the data folder?

@MaxSchlueter
Copy link
Author

I created the backup by exporting a workout.

@blockbasti
Copy link
Owner

I can't reproduce this on my device. Can you provide me with the backup file, so i can try it myself?

@MaxSchlueter
Copy link
Author

MaxSchlueter commented Oct 9, 2021

Sure, this is the content of the exported workout (Test.json):

{
  "workouts": [
    {
      "title": "Test",
      "sets": [
        {
          "repetitions": 1,
          "id": "265d3e45-1f21-49ea-b9d4-7336f968cb3a",
          "exercises": [
            {
              "name": "Exercise",
              "id": "73492695-08a3-487f-b52a-cb9cc5051a63",
              "duration": 30
            }
          ]
        }
      ],
      "version": 2,
      "position": 10
    }
  ]
}

@blockbasti
Copy link
Owner

I imported the file successfully on my real device and dev emulator.

@MaxSchlueter
Copy link
Author

I could import the file successfully as well on my old smartphone which is running Android 7. It's still not working on my current one, a Pixel 2 running Android 11 (Lineage OS).

@Franziskus1988
Copy link
Contributor

I'm using a Xiaomi Mi 8 with the latest Lineage OS 18.1 and it is not working, too.

@Franziskus1988
Copy link
Contributor

@blockbasti

So, I debugged the app and the importing and I think I found the problem:
In storage_helper.dart:48 you are importing the data with the

var backup = await File(filePath).readAsString();

In my case this throws an exception due to an malformed utf8 encoding. I'm not very experienced in Android/Flutter development so I "DuckDuckGo-ed" and found a similar problem here: dart-lang/pana#759

After changing the above code to

    var bytes = await File(filePath).readAsBytes();
    var backup = utf8.decode(bytes, allowMalformed: true);

it works perfectly fine! Of course you could follow the discussion from the mentioned link to write this a little bit nicer and don't allowMalformed per default ;)

Hope this helped.

@blockbasti
Copy link
Owner

@Franziskus1988 thank you for finding this. Could you please create a pull request with these changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants