Retrieve storage numeric id earlier when still available

The numeric id is only available before the storage entry is deleted, so
get it at that time.

Backport of d485c0098d58454b8dbd25e574a363a500244942 from master