Skip to content

Commit

Permalink
Minor Improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
AliRn76 committed Dec 18, 2023
1 parent 4d0bd26 commit 51ae75c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pantherdb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pantherdb.pantherdb import * # noqa: F403

__version__ = '1.3.3'
__version__ = '1.3.4'


__all__ = ('__version__', 'PantherDB', 'PantherCollection', 'PantherDocument', 'PantherDBException')
24 changes: 12 additions & 12 deletions pantherdb/pantherdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,22 @@ def _write(self) -> None:
file.write(content)

def _refresh(self) -> None:
# TODO: Find Solution, so won't refresh on every single query
with open(self.db_name, 'rb') as file:
data = file.read()

if not (data := file.read()):
self.__content = {}
if not data:
self.__content = {}

elif not self.secret_key:
self.__content = json.loads(data)
elif not self.secret_key:
self.__content = json.loads(data)

else:
try:
decrypted_data: bytes = self.__fernet.decrypt(data)
self.__content = json.loads(decrypted_data)
except InvalidToken:
error = '"secret_key" Is Not Valid'
raise PantherDBException(error)
else:
try:
decrypted_data: bytes = self.__fernet.decrypt(data)
self.__content = json.loads(decrypted_data)
except InvalidToken:
error = '"secret_key" Is Not Valid'
raise PantherDBException(error)

def collection(self, collection_name: str) -> PantherCollection:
return PantherCollection(
Expand Down

0 comments on commit 51ae75c

Please sign in to comment.