diff --git a/ci-storage b/ci-storage index 5509481..254ba7f 100755 --- a/ci-storage +++ b/ci-storage @@ -257,9 +257,10 @@ def action_load( # Write hints, so next time we call "store" action, we don't # have to pass them again, the hints will be derived from # the "load" action. - meta = SlotMeta.read_from(local_dir=local_dir) - meta.hints = hints - meta.write_to(local_dir=local_dir) + if hints: + meta = SlotMeta.read_from(local_dir=local_dir) + meta.hints = hints + meta.write_to(local_dir=local_dir) return elif not layer: slot_id = infer_best_slot_to_load_full_from( @@ -309,10 +310,14 @@ def action_load( if not layer: slot_info = slot_infos[slot_id] - # We update full_snapshot_history to remember the actual slot "*" has - # just loaded from, to allow the next "store" action better choose the - # "dedupping" slot with --link-dest. + # We update full_snapshot_history to remember the actual slot "*" we + # have just loaded from, to allow the next "store" action better choose + # the "dedupping" slot with --link-dest. slot_info.meta.full_snapshot_history.insert(0, slot_id) + # Write hints, so next time we call "store" action, we don't have to + # pass them again, the hints will be derived from the "load" action. + if hints: + slot_info.meta.hints = hints slot_info.meta.write_to(local_dir=local_dir) @@ -429,6 +434,7 @@ def action_clean( ], print_elapsed=True, ) + SlotMeta().write_to(local_dir=local_dir) finally: try: os.rmdir(empty_dir) diff --git a/tests/0030-load-star-does-clean-when-no-slots-in-storage.test.sh b/tests/0030-load-star-does-clean-when-no-slots-in-storage.test.sh index b24b7dd..d33b609 100755 --- a/tests/0030-load-star-does-clean-when-no-slots-in-storage.test.sh +++ b/tests/0030-load-star-does-clean-when-no-slots-in-storage.test.sh @@ -4,11 +4,13 @@ source ./common.sh test -e "$LOCAL_DIR/file-1" test -e "$LOCAL_DIR/dir-a" +echo "hints=old" > "$LOCAL_META_FILE" + ci-storage \ --slot-id="*" \ load grep -qF 'Checking slot-id="*"... storage has no slots, so cleaning' "$OUT" - +grep -qE "hints=$" "$LOCAL_META_FILE" test ! -e "$LOCAL_DIR/file-1" test ! -e "$LOCAL_DIR/dir-a" diff --git a/tests/0035-load-star-saves-hints-to-local-meta-and-uses-them-at-store.test.sh b/tests/0035-load-star-saves-hints-to-local-meta-and-uses-them-at-store-when-there-was-recent-slot.test.sh similarity index 100% rename from tests/0035-load-star-saves-hints-to-local-meta-and-uses-them-at-store.test.sh rename to tests/0035-load-star-saves-hints-to-local-meta-and-uses-them-at-store-when-there-was-recent-slot.test.sh diff --git a/tests/0036-load-star-saves-hints-to-local-meta-and-uses-them-at-store-when-no-slots-initially.test.sh b/tests/0036-load-star-saves-hints-to-local-meta-and-uses-them-at-store-when-no-slots-initially.test.sh new file mode 100755 index 0000000..af868e6 --- /dev/null +++ b/tests/0036-load-star-saves-hints-to-local-meta-and-uses-them-at-store-when-no-slots-initially.test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +source ./common.sh + +ci-storage \ + --slot-id=myslot0 \ + store + +ci-storage \ + --slot-id="*" \ + --hint="aaa" \ + load + +grep -qF "hints=aaa" "$LOCAL_META_FILE" + +ci-storage \ + --slot-id=myslot1 \ + --hint="" \ + store + +grep -qF "hints=aaa" "$STORAGE_DIR/myslot1/.ci-storage.meta"