phonegap / phonegap-plugin-contentsync

Download and cache remotely hosted content
Apache License 2.0
206 stars 98 forks source link

iOS Simulator behaviour #30

Closed kaansoral closed 9 years ago

kaansoral commented 9 years ago

How does this plugin supposed to behave on the iOS Simulator?

I persist the contentsync folder with localStorage, currently, on the simulator, the contentsync folder is missing

/Users/me/Library/Developer/CoreSimulator/Devices/A7BE80E3-0BEF-48DD-81CA-F48A0FED3DB2/data/Containers/Data/Application/6E81D19F-2349-4D3E-9C4A-85831EF3EED3/Library/mlib/ is the folder A7BE80E3-0BEF-48DD-81CA-F48A0FED3DB2 exists 6E81D19F-2349-4D3E-9C4A-85831EF3EED3 doesn't exist

an existence check routine might have been nice

I have no idea how to debug this issue, I'm also unsure whether the issue is unique to the simulator, would appreciate some advice at this point, thanks :)

kaansoral commented 9 years ago

After researching the issue, I'm guessing it might be because the simulator session wasn't saved and the simulator terminated before it did, as far as I read the simulator runs on memory and persists the storage periodically or on demand (?)

imhotep commented 9 years ago

@kaansoral the reason is because Apple doesn't want you to store/rely on the UUID of your application. The best way in your case is to set options.type to local which would return the path to the local copy of your folder (by id) if it exists or would act as "replace" if it doesn't (which means download/extract/..).

kaansoral commented 9 years ago

Thanks, it's perfect :)

I didn't pay attention to the "local" option when I was reading the documentation, it's certainly a very well thought feature

I was caching the path myself, but now I'm just calling the ContentSync plugin with the "local" option if there is a cached flag in localStorage

macdonst commented 9 years ago

@kaansoral can we consider this issue to be resolved? If so feel free to close it or leave a comment indicating it is resolved.

kaansoral commented 9 years ago

Sorry, it's resolved, thanks :)