Skip to content

Commit 3d37888

Browse files
authored
Merge pull request HKUDS#263 from detaos/detaos-patch-1
Only update storage if there was something to insert
2 parents d904f2a + 83f8a51 commit 3d37888

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎lightrag/lightrag.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def insert(self, string_or_strings):
227227
return loop.run_until_complete(self.ainsert(string_or_strings))
228228

229229
async def ainsert(self, string_or_strings):
230+
update_storage = False
230231
try:
231232
if isinstance(string_or_strings, str):
232233
string_or_strings = [string_or_strings]
@@ -240,6 +241,7 @@ async def ainsert(self, string_or_strings):
240241
if not len(new_docs):
241242
logger.warning("All docs are already in the storage")
242243
return
244+
update_storage = True
243245
logger.info(f"[New Docs] inserting {len(new_docs)} docs")
244246

245247
inserting_chunks = {}
@@ -286,7 +288,8 @@ async def ainsert(self, string_or_strings):
286288
await self.full_docs.upsert(new_docs)
287289
await self.text_chunks.upsert(inserting_chunks)
288290
finally:
289-
await self._insert_done()
291+
if update_storage:
292+
await self._insert_done()
290293

291294
async def _insert_done(self):
292295
tasks = []

0 commit comments

Comments
 (0)