Hi, I saw this within zipline's <readme> - ```Modu...
# squarelibraries
j
Hi, I saw this within zipline's readme -
Copy code
Modules can also be embedded with the host application to avoid any downloads if the network is unreachable
Is there any documentation/sample that demonstrates how this can be achieved?
a
You can use the ZiplineLoader's withEmbedded function. It takes in an Okio FileSystem and a path. Just make sure you use the Zipline CLI for downloading the embeddable files because they need to be renamed to their SHAs
1
j
thanks, let me try that @Aditya Kurkure thank you color
I was able to download the files but the command does not exit by itself, not sure if everything got downloaded or it got stuck. And where exactly do we need to add these files so that it can be picked up via
withEmbedded
? Also, with
withCache()
enabled, zipline loader tries to fetch from network and fails after app restarts while internet is turned off. Is this expected?
a
You have to run the CLI tool in the parent directory of
bin
as shown in the readme, any other directory doesn't work for me either (Maybe from misconfig on my part). The manifest call would still be sent even with caching enabled, if the network request fails it would then use the cached / embedded manifest. The binaries work differently though, the order is embedded, cache, network.
And where exactly do we need to add these files so that it can be picked up via
withEmbedded
?
It takes in a file system and a path so if you use the assets file system for example, (only for android), place it in the assets folder of the module and give it the corresponding path.
j
You have to run the CLI tool in the parent directory of
bin
as shown in the readme
yes the command runs fine, but fails to exit so unsure if it was able to finish.
The manifest call would still be sent even with caching enabled, if the network request fails it would then use the cached / embedded manifest.
this doesn't seem to be happening tho.
It takes in a file system and a path so if you use the assets file system for example, (only for android), place it in the assets folder of the module and give it the corresponding path.
Is there an example for this somewhere? If its within assets, can we access path relatively or does it have to be from some root? or would it be a URI situation?
@jessewilson just curious, is there a plan to create documentations for all this? Is something already in the works?
a
this doesn't seem to be happening tho.
Are you using load once by any chance?
j
Yes @Aditya Kurkure
a
It should work with load, load once will just return the failure result form the load from network call.
j
Interesting. Will try
load
and get back. Thanks again @Aditya Kurkure
j
Yeah, we might do good by making a doc specifically on ZiplineLoader and how to use it effectively
🙌 1
j
@Aditya Kurkure using
load
worked. Thanks. 🫡 Would you be able to help with how embedded source can be achieved for android/iOS?
When we say embedded, I'm assuming that it is meant be part of the distributed apk/ipa, and in that case, how would passing a local filesystem path work for the loader through
embeddedDir
? Got the cache working when I tried using
FileSystem.SYSTEM_TEMPORARY_DIRECTORY
, but not quite sure if this is how its expected to be configured. A doc/example would be of incredible help, couldn't find any relevant usage of these methods on any other OS projects on github for reference.
j
The embedded dir is expected to be Okio’s RESOURCES file system
💪 1
At least for APKs
We’ve also got one that’s more efficient for Android, https://github.com/square/okio/tree/master/okio-assetfilesystem
thank you color 1
j
Will try these out @jessewilson. What's recommended for iOS?
j
That I don’t know! Lemme get back to you
thank you color 1
a
You can add then to your main bundle and use the SYSTEM FileSystem. That works for us. Could not get resource file system working on either platform. 😕
🥲 1
j
@Aditya Kurkure how does
FileSystem.SYSTEM
access things on the bundle/apk? Do you have additional code that copies it to local for the first time? Or does this run without any of that hack? Would you be able to share some snippets how to do this on android/iOS?
a
For android you can use the asset fileSystem as @jessewilson suggested, that works for us. You don't need to copy the code at runtime, at compile time you can download it from your server using the zipline CLI, to the android modules
assets
folder.
1
j
Awesome, this is helpful, thank you so much. gratitude thank you