Closed MaxSchlueter closed 2 years ago
Did you create the backup by exporting a workout or did you just copy the files from the data folder?
I created the backup by exporting a workout.
I can't reproduce this on my device. Can you provide me with the backup file, so i can try it myself?
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
}
]
}
I imported the file successfully on my real device and dev emulator.
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).
I'm using a Xiaomi Mi 8 with the latest Lineage OS 18.1 and it is not working, too.
@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: https://github.com/dart-lang/pana/pull/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.
@Franziskus1988 thank you for finding this. Could you please create a pull request with these changes?
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:
Expected behavior Would expect the workout to show up in the list.
Smartphone (please complete the following information):