microsoft / cordova-plugin-code-push

Cordova plugin for CodePush
http://appcenter.ms
Other
643 stars 332 forks source link

Plugin requires that iosExtraFilesystems contains library-nosync, but this is not documented #605

Open elijahr opened 4 years ago

elijahr commented 4 years ago

Description

fileUtil references cordova.file.dataDirectory in several places. According to cordova's docs, cordova.file.dataDirectory is available if iosExtraFilesystems includes library-nosync. The default value for iosExtraFilesystems includes library-nosync, so for many users, there is no issue.

However, if a developer's config.xml explicitly specifies an iosExtraFilesystems which does not include library-nosync, codePush will behave in unexpected ways. From what I was seeing, one of several things could happen, inconsistently:

  1. The remote package would install correctly, and on app restart, the update would apply and everything would work as expected.
  2. The remote package would install correctly, and on app restart, the update would apply. On subsequent restarts, the update would be rolled back, despite notifyApplicationReady() having been called on each app start.
  3. The remote package would download but fail to install. It would fail with a rather unhelpful "Cannot perform diff-update." error message.

I suspect that this is because when library-nosync is not specified, the corresponding directory Library/NoCloud/ is still created by FileUtil.getDirectory(), but is synchronized to iCloud, since it is a subdirectory of Library/. It's not clear to me why this makes a difference, but it may have to do with a user's available iCloud storage space (I am maxed out on storage at the moment, but this issue was affecting most of our end users). It may be something else; the behavior of reading/writing data in Library/NoCloud without library-nosync is unspecified.

Adding library-nosync to iosExtraFilesystems fixed codePush for me; the updates consistently finished installing and "stuck". I couldn't find any documentation on this requirement, though I did find this unresolved issue that seemed possibly related.

Given that fileUtil references cordova.file.dataDirectory, and cordova.file.dataDirectory is only configured correctly if library-nosync is specified, at the very least this requirement should be documented somewhere. More ideally, the build should fail if iosExtraFilesystems does not contain library-nosync, a more helpful error message should be shown, or the plugin should simply override/append the library-nosync value to iosExtraFileSystems if it is not present.

Reproduction

Create a cordova application with the following additional configuration:

    <preference name="iosExtraFilesystems" value="library" />
    <plugin name="cordova-plugin-code-push" />

And observe that updates do not consistently install or "stick".

Additional Information

phyr0s commented 4 years ago

@elijahr i think that your issue is related to this --> https://github.com/microsoft/cordova-plugin-code-push/pull/608

Krasavinigor commented 4 years ago

Hi @elijahr! Thank you for reporting! We reproduced this issue. We will investigate it as soon as possible.