Skip to content

Commit

Permalink
fix: slide-search rm dumped files if they are rmed in the source (#6947)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 5cae9b0388e3bf121f00bf6331e13abec07e65ae
  • Loading branch information
berkecanrizai authored and Manul from Pathway committed Jul 23, 2024
1 parent f35f1d4 commit 4212ec4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions examples/pipelines/slides_ai_search/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,16 @@ def dump_img_callback(key, row, time, is_addition):
def dump_file_callback(key, row, time, is_addition):
# save parsed files
file_name = row["path"].value.split("/")[-1]
with open(f"{FILE_DUMP_FOLDER}/{file_name}", "wb") as f:
f.write(row["data"])
file_path = f"{FILE_DUMP_FOLDER}/{file_name}"
if is_addition:
with open(file_path, "wb") as f:
f.write(row["data"])
else:
try:
os.remove(file_path)
logging.info(f"Removed file: {file_path}")
except Exception as e:
logging.info("Error removing %s: %s", file_name, e)


if __name__ == "__main__":
Expand Down

0 comments on commit 4212ec4

Please sign in to comment.