-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
endlesskey: Import only specified content in collections #141
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,28 +8,30 @@ if [[ ! "${EIB_FLATPAK_REMOTE_FLATHUB_APPS}" =~ .*"org.endlessos.Key".* ]]; then | |
exit 0 | ||
fi | ||
|
||
# Get the list of channels to preload. | ||
selected_collection_files=() | ||
|
||
channels_file="${EIB_TMPDIR}"/ek-channels | ||
rm -f "${channels_file}" | ||
touch "${channels_file}" | ||
collections="${OSTREE_VAR}"/lib/flatpak/app/org.endlessos.Key/current/active/files/share/endless-key/collections/*.json | ||
for collection in ${collections}; do | ||
all_collection_files="${OSTREE_VAR}"/lib/flatpak/app/org.endlessos.Key/current/active/files/share/endless-key/collections/*.json | ||
for collection_file in ${all_collection_files}; do | ||
# Check if the file basename stripped off of -0001.json is part of the list | ||
# of collections to be installed. | ||
bn=$(basename ${collection}) | ||
bn=$(basename ${collection_file}) | ||
if [[ "${EIB_ENDLESSKEY_COLLECTIONS}" =~ .*"${bn%-????.json}".* ]] ; then | ||
jq -r '.channels[].id' "${collection}" >> "${channels_file}" | ||
selected_collection_files+=("${collection_file}") | ||
jq -r '.channels[].id' "${collection_file}" >> "${channels_file}" | ||
fi | ||
done | ||
|
||
channels=$(sort -u "${channels_file}") | ||
if [ -z "${channels}" ]; then | ||
all_channels=$(sort -u "${channels_file}") | ||
if [ -z "${all_channels}" ]; then | ||
echo "No Kolibri channels to preload" | ||
exit 0 | ||
fi | ||
|
||
# Seed the needed channels on the content server. | ||
"${EIB_HELPERSDIR}"/seed-kolibri-channels ${channels} | ||
"${EIB_HELPERSDIR}"/seed-kolibri-channels ${all_channels} | ||
|
||
venv_dir="${EIB_TMPDIR}/kolibri-content-venv" | ||
python3 -m venv ${venv_dir} | ||
|
@@ -48,14 +50,35 @@ if [ -n "${EIB_KOLIBRI_CENTRAL_CONTENT_BASE_URL}" ]; then | |
export KOLIBRI_CENTRAL_CONTENT_BASE_URL | ||
fi | ||
|
||
for channel in $channels; do | ||
# Import all channel metadata and thumbnails for all channels | ||
for channel in $all_channels; do | ||
kolibri manage --skip-update importchannel network "${channel}" | ||
EIB_RETRY_ATTEMPTS=2 EIB_RETRY_INTERVAL=30 eib_retry \ | ||
kolibri manage --skip-update \ | ||
importcontent --include-unrenderable-content --fail-on-error \ | ||
--node_ids="" --all-thumbnails \ | ||
network "${channel}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, this should only be in the not full channels branch below. The full channels branch is obviously already going to import all the thumbnails. Not a big deal, though. |
||
done | ||
|
||
if [ "${EIB_ENDLESSKEY_INCLUDE_FULL_CHANNELS}" == true ]; then | ||
for channel in $all_channels; do | ||
EIB_RETRY_ATTEMPTS=2 EIB_RETRY_INTERVAL=30 eib_retry \ | ||
kolibri manage --skip-update \ | ||
importcontent --include-unrenderable-content --fail-on-error \ | ||
network "${channel}" | ||
done | ||
else | ||
for collection_file in "${selected_collection_files[@]}"; do | ||
collection_channels=$(jq -r '.channels[].id' "${collection_file}") | ||
for channel in $collection_channels; do | ||
EIB_RETRY_ATTEMPTS=2 EIB_RETRY_INTERVAL=30 eib_retry \ | ||
kolibri manage --skip-update \ | ||
importcontent --include-unrenderable-content --fail-on-error \ | ||
--manifest="${collection_file}" network "${channel}" | ||
done | ||
done | ||
fi | ||
|
||
# Empty the user database, and ensure that each instance of this image has a | ||
# unique Facility ID. | ||
# <https://kolibri.readthedocs.io/en/latest/install/provision.html#prepare-the-kolibri-folder-for-copying> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want to also include
extras
or this won't work offline. The explore plugin will try to import all the thumbnails from nodes in theextras
pack at runtime. See https://github.com/endlessm/kolibri-explore-plugin/blob/master/kolibri_explore_plugin/collectionviews.py#L43. I think it's fine to import whatever nodes are specified in it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, that's a good one. I pushed a change just now (4583308) getting it to download all thumbnails for all the included channels.
Alas, adding the
extras
collection is a bit problematic, since that manifest file includes a bunch of content as well. But it probably shouldn't? I proposed endlessm/endless-key-collections#37 just now to address that, and then I can add it here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The collections change was merged, released, and included in an org.endlessos.Key flathub release. So, I think this should be good now.