Compare commits

..

10 Commits

View File

@ -271,18 +271,24 @@ class ChatDB(Chat):
self.messages += new_messages
self.sort()
def write_db(self) -> None:
def write_db(self, msgs: Optional[list[Message]] = None) -> None:
"""
Write all messages to the DB directory. If a message has no file_path,
a new one will be created. If message.file_path exists, it will be modified
to point to the DB directory.
Write messages to the DB directory. If a message has no file_path, a new one
will be created. If message.file_path exists, it will be modified to point
to the DB directory.
"""
write_dir(self.db_path, self.messages, self.file_suffix, self.get_next_fid)
write_dir(self.db_path,
msgs if msgs else self.messages,
self.file_suffix,
self.get_next_fid)
def write_cache(self) -> None:
def write_cache(self, msgs: Optional[list[Message]] = None) -> None:
"""
Write all messages to the cache directory. If a message has no file_path,
a new one will be created. If message.file_path exists, it will be modified
to point to the cache directory.
Write messages to the cache directory. If a message has no file_path, a new one
will be created. If message.file_path exists, it will be modified to point to
the cache directory.
"""
write_dir(self.cache_path, self.messages, self.file_suffix, self.get_next_fid)
write_dir(self.cache_path,
msgs if msgs else self.messages,
self.file_suffix,
self.get_next_fid)