[TIMOB-23141] iOS: Ti.Filesystem.File.remoteBackup = true doesn't (re)include file to be backed up
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-06-28T05:37:00.000+0000 |
Affected Version/s | Release 5.2.1 |
Fix Version/s | Release 5.4.0 |
Components | iOS |
Labels | backup, icloud, ios, itunes |
Reporter | Gary Crook |
Assignee | Hans Knöchel |
Created | 2016-04-02T18:53:56.000+0000 |
Updated | 2016-07-28T20:05:43.000+0000 |
Description
If you never use the Ti.Filesystem.File.remoteBackup property or Ti.Filesystem.File.setRemoteBackup method, then files are properly included in iTunes/iCloud backups as default. So far, so good.
If however, like I did in my project, you manually set remoteBackup = true or call setRemoteBackup(true) on a file to doubly make sure it gets backed up, it actually becomes excluded.
I've had reports from users that their copy of my app (live on the App Store) was not fully restoring their data from a backup. The files I'd set the flag = true on were some .png's in /Documents and a SQLite database in /Library/Private Documents, but I think the problem is evident for any files.
I delved into the SDK code for 5.2.1 and located remoteBackup in TiFilesystemFileProxy.m - after a bit of Googling I noticed that how the method works by calling
setxattr()
is now obsolete. Apple states that from iOS 5.1 you should be doing it this way: [https://developer.apple.com/library/ios/qa/qa1719/_index.html]
I modified my copy of TiFilesystemFileProxy.m to work this way and next time I called setRemoteBackup(true) the file was properly marked for backup, i.e. NSURLIsExcludedFromBackupKey
is set to NO
.
I tested this against a local iTunes backup. You can check the contents of an iTunes backup using the Terminal command:
{noformat}
/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/AppleMobileDeviceHelper.app/Contents/Resources/AppleMobileBackup --list
{noformat}
Prior to my temporary Obj-C code fix my files were not listed in the backup. After adding my fix the files were listed in the backup correctly.
Hey there! Did I quick follow-up and you are correct! Can you copy-and-paste the following snippet and test it? https://gist.github.com/hansemannn/676a9c7ca35c2f29212d19bddd4a135a PR: https://github.com/appcelerator/titanium_mobile/pull/7910 EDIT: Demo code here:
[~pragmateq] Thanks for the report and the suggested solution! We have implemented the solution but would appreciate very much if you can validate it as well, as requested in the above comment. Thanks again!
Hi, I've just tested in my app and the files appear in iTunes backup log when
file.setRemoteBackup(true)
and disappear from iTunes backup log whenfile.setRemoteBackup(false)
. So looks fixed to me - good work! Gary.Thanks! PR Merged.
I think I've just had my app rejected from the App Store because of this 'fix'. For the longest time (since Ti SDK3) I've used the recursive directory version of this to set all files in a folder to being remoteBackup = false. My app has just been rejected using the latest SDK saying that 38mb download was not flagged as being excluded. I've triple checked and this is being set at the directory level. I think this needs to be re-opened and checked for the recursive version still working.
Hey there! It most possibly is the same as mentioned here: http://www.scriptscoop2.com/t/bafdaa0216be/iphone-is-nsurlisexcludedfrombackupkey-recursive.html, so it doesn't apply the flag recursively. I could make the change by looping through the directory and setting the flag there, could you be my tester for that? Thanks!
Update: Here is my example code to create a directory with 20 sub-directories, as well as one file in it (to cover all possible scenarios - skipping if empty). *Demo*: https://gist.github.com/hansemannn/496308a44dcbeffb8ecf1973a69246bf *Output*: https://gist.github.com/hansemannn/0e5c0b704eb3056c7f16a33007096adb *Updated PR*: https://github.com/appcelerator/titanium_mobile/pull/8069 [~mark.henderson@snagr.co.uk] Please give it a try! [~cng] Backport for 5.4.0 as soon as the fix is approved, thanks!
CR and FT passed. backport please.
PR (5_4_X): https://github.com/appcelerator/titanium_mobile/pull/8093
PRs merged!
[~hansknoechel] Using SDK 5.4.0, I was able to verify this fix while checking the contents of the iTunes backup: *SDK 5.3.1.GA*
*SDK 5.4.0.v20160727143921*
*However,* this log message keeps appearing every time I use
setRemoteBackup
:\[INFO\] CFURLSetResourcePropertyForKey failed because it was passed an URL which has no scheme
. Did a Google search and found this stackoverflow link: http://stackoverflow.com/questions/12928509/cfurlsetresourcepropertyforkey-failed-when-disable-data-backup-on-nsdocumentdire, which seems to be done here: https://github.com/appcelerator/titanium_mobile/pull/8093/files#diff-7c1c034158d43375ccc8ec33c21f4257R513. Should we be concerned about that log message? *Tested on:* Appc CLI NPM: 4.2.7 Appc CLI Core: 5.4.0-35 Arrow: 1.8.2 SDK: 5.4.0.v20160727143921 Node: v4.4.7 OS: Mac OS X (10.11.6) Xcode: 7.3.1 Device: iphone 5 (9.1) Also, had to modify your demo code a bit:Will close ticket as fixed as per my above comment. Will file another ticket for the
[INFO] CFURLSetResourcePropertyForKey failed because it was passed an URL which has no scheme
message.