Skip to content

Commit

Permalink
add canister logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dskloetd committed Jul 26, 2024
1 parent 4a791c3 commit 21be198
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions rs/backend/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ pub fn init_assets() {
/// - If the decompression fails or the tarball cannot be parsed.
#[allow(clippy::needless_pass_by_value)]
pub fn insert_tar_xz(compressed: Vec<u8>) {
ic_cdk:: println!("add_assets_tar_xz in over after insert_tar_xz");
println!("Inserting assets...");
let mut num_assets = 0;
let mut decompressed = Vec::new();
Expand Down
5 changes: 5 additions & 0 deletions rs/backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,19 @@ pub fn add_stable_asset() {
/// - Permission to upload may be denied; see `may_upload()` for details.
#[export_name = "canister_update add_assets_tar_xz"]
pub fn add_assets_tar_xz() {
ic_cdk::println!("add_assets_tar_xz before over");
over(candid_one, |asset_bytes: Vec<u8>| {
ic_cdk::println!("add_assets_tar_xz in over");
let caller = ic_cdk::caller();
let is_controller = ic_cdk::api::is_controller(&caller);
assets::upload::may_upload(&caller, is_controller)
.map_err(|e| format!("Permission to upload denied: {e}"))
.unwrap();
ic_cdk::println!("add_assets_tar_xz in over before insert_tar_xz");
insert_tar_xz(asset_bytes);
ic_cdk::println!("add_assets_tar_xz in over after insert_tar_xz");
});
ic_cdk::println!("add_assets_tar_xz after over");
}

/// Generates a lot of toy accounts for testing.
Expand Down
17 changes: 15 additions & 2 deletions scripts/nns-dapp/split-assets
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ clap.define short=o long=out desc="The output directory; a subdirectory 'chunks'
# Source the output file ----------------------------------------------------------
source "$(clap.build)"

# we need GNU tar so we check early
if tar --help | grep GNU >/dev/null; then
echo "found GNU tar as tar"
tar="tar"
elif command -v gtar >/dev/null; then
echo "found GNU tar as gtar"
tar="gtar"
else
echo "did not find GNU tar, please install"
echo " brew install gnu-tar"
exit 1
fi

ORIGINAL_ASSETS_TAR_XZ="$(realpath "$ORIGINAL_ASSETS_TAR_XZ")"
test -d "$OUTPUT_DIR" || {
echo "ERROR: The output directory should exist: '$OUTPUT_DIR'"
Expand All @@ -37,7 +50,7 @@ WORKDIR="$(mktemp -d)"
cd "$WORKDIR"
mkdir assets
cd assets
tar -Jxf "$ORIGINAL_ASSETS_TAR_XZ"
"$tar" -Jxf "$ORIGINAL_ASSETS_TAR_XZ"
)

# Prints paths of assets in the tarball
Expand Down Expand Up @@ -82,7 +95,7 @@ FILES_PER_CHUNK="$(
cd assets
list_manifests | while read -r chunk_manifest; do
chunk_name="$WORKDIR/chunks/assets.$(basename "$chunk_manifest").tar.xz"
tar cJ \
"$tar" cJ \
--mtime='2021-05-07 17:00Z' \
--sort=name \
--owner=0 \
Expand Down

0 comments on commit 21be198

Please sign in to comment.