vaphes / pocketbase

PocketBase client SDK for python
https://pypi.org/project/pocketbase/
MIT License
332 stars 38 forks source link

creating LocalAuthStore with at an empty location leads to FileNotFoundError error in _storage_get() #47

Closed m29h closed 1 year ago

m29h commented 1 year ago

I try to prepare a local auth store where to save the token.

    tmp = tempfile.mkdtemp()
    l_store = LocalAuthStore(filepath=tmp)
    la_client = PocketBase(client.base_url, auth_store=l_store)
    la_client.auth_store.save(client.auth_store.token, client.auth_store.model)

However LocalAuthStore raises an error when running for the first time as it cannot load the file (that is not there yet). I recommend to make this less error prone and treat a missing file identical to an empty file. note that also the LocalAuthStore.clear() function deletes the storage file and leads to an exception next time the store is tried to be loaded.