I’m trying to create an Anbox application where new instances will have some images in the media/Pictures directory that the user of the device can see and use.
I’ve tried placing the image files in a folder in my application definition and then copying them to where I think they should go in my post-start hook like so:
if [ "$INSTANCE_TYPE" = "regular" ]; then
exit 0
fi
cp /var/lib/anbox/app/media/* /var/lib/anbox/data/media/0/Pictures
I get the following error:
target '/var/lib/anbox/data/media/0/Pictures' is not a directory
This directory does exist on the completed instance once I’ve connected, but it doesn’t seem to when the hook is being run.
Should I copy the files somewhere else, or is there another way to do this?
Hey @al-p
Thanks for reaching out.
You’ve encountered a timing issue. At the point when the post-stop hook is executed for a base instance, the path /var/lib/anbox/data/media/0 and its subdirectories have not been fully created and initialized by the volume daemon (vold). The following logs imply that:
To mitigate this situation, you could check for the existence of the target directory before executing the cp command. Hopefully, this would be helpful.