lib: Don't suppress errors from inside the DataFile context manager

And fix up the trackdb to check if the file exists before attempting to
unpickle.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-06-07 10:02:35 -04:00
parent 2083d00c23
commit 7b901b8380
2 changed files with 3 additions and 2 deletions

View File

@ -34,7 +34,7 @@ class DataFile:
if self.mode == WRITE:
self.temp.replace(self.path)
self.file = None
return True
return exp_type == None
def exists(self):
return self.path.exists()

View File

@ -65,7 +65,8 @@ def save(*args):
def load():
global library_paths
with data.DataFile(db_file, data.READ) as f:
(library.NextID, library_paths) = f.unpickle()
if f.exists():
(library.NextID, library_paths) = f.unpickle()
def __register_callbacks():
LibraryAdded.register(save)