NativeScript / nativescript-app-sync

♻️ Update your app without going through the app store!
MIT License
125 stars 24 forks source link

Files written to the file-system are lost after update #20

Closed shiv19 closed 5 years ago

shiv19 commented 5 years ago

We noticed that after an AppSync update, the files that the app writes to the file system are lost. However, things stored in App-Settings remain intact.

EddyVerbruggen commented 5 years ago

Hmm, interesting one. Can you tell me how you wrote to the fs (a snippet would be helpful) and which platforms are affected?

shiv19 commented 5 years ago
import { knownFolders } from 'tns-core-modules/file-system';
const documents = knownFolders.documents();
const jsonFile = documents.getFile('/app/something.json');
jsonFile.readText().then(function(content) {}); // for read
jsonFile.writeText(text).then(function() {}); // for write

Something like this. And I realize that files are being written into app folder in this app.

shiv19 commented 5 years ago

@EddyVerbruggen I believe this affects both Android and iOS since the files are in app folder. But I haven't tested it on iOS

EddyVerbruggen commented 5 years ago

Thanks for the snippet. Looking at this today and reporting my findings here. Note that an iOS sim and device behave differently, so that's why I'll test both of those separately.

EddyVerbruggen commented 5 years ago

Hey @shiv19, can you please give version 1.0.2 a try?

On Android (only) I used to rename the /app folder to /app_backup and then rename the folder with the pending update to /app. So that's why files saved to /app were lost. I guess if you save to different folders there wouldn't be an issue.

I've now updated the algorithm to instead copy the new files over the current /app folder, so anything already there won't be removed.

shiv19 commented 5 years ago

Thanks @EddyVerbruggen I'll give it a try today :)

shiv19 commented 5 years ago

@EddyVerbruggen It worked! :D Thank you

EddyVerbruggen commented 5 years ago

Woohoo, thx for testing this!