Spaces:
Paused
Paused
Download client/src/sync/persistentStorage.ts from Leon4gr45/augmenttoolkit: direct link, hf CLI and curl.
- Browser
- Download file 792 Bytes
-
https://huggingface.co/spaces/Leon4gr45/augmenttoolkit/resolve/bb4da7e5d448e08c0375f8cfd152cb4fdc024f92/client/src/sync/persistentStorage.ts
- Command line
-
hf download hf://spaces/Leon4gr45/augmenttoolkit@bb4da7e5d448e08c0375f8cfd152cb4fdc024f92/client/src/sync/persistentStorage.ts
-
curl -L -o persistentStorage.ts https://huggingface.co/spaces/Leon4gr45/augmenttoolkit/resolve/bb4da7e5d448e08c0375f8cfd152cb4fdc024f92/client/src/sync/persistentStorage.ts
792 Bytes
| /** | |
| * Ask the browser for persistent storage so our offline data — prefetched map | |
| * tiles, cached file blobs, the IndexedDB caches — is exempt from eviction under | |
| * storage pressure. Without this the browser may purge tiles right when a | |
| * traveler goes offline and needs them (audit H8 / M6). | |
| * | |
| * Best-effort and idempotent: returns whether persistence is (now) granted. | |
| */ | |
| export async function requestPersistentStorage(): Promise<boolean> { | |
| try { | |
| if (typeof navigator === 'undefined' || !navigator.storage?.persist) return false | |
| // Already persisted? Avoid re-prompting where the API distinguishes. | |
| if (navigator.storage.persisted && (await navigator.storage.persisted())) return true | |
| return await navigator.storage.persist() | |
| } catch { | |
| return false | |
| } | |
| } | |