Skip to content

Commit 4e0786c

Browse files
committed
Narrows scope of empty directory delete to ingest files parent folder
1 parent 19960a9 commit 4e0786c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

scripts/ingest_processor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ def convert_to_kepub(self) -> tuple[bool,str]:
168168
def delete_current_file(self) -> None:
169169
"""Deletes file just processed from ingest folder"""
170170
os.remove(self.filepath) # Removes processed file
171-
subprocess.run(["find", f"{self.ingest_folder}", "-mindepth", "1", "-type", "d", "-empty", "-delete"]) # Removes any now empty folders in the ingest folder
171+
if os.path.dirname(self.filepath) != self.ingest_folder: # File was in ingest_folder, no directories to delete
172+
subprocess.run(["find", f"{os.path.dirname(self.filepath)}", "-type", "d", "-empty", "-delete"]) # Removes any now empty folders including parent directory
172173

173174

174175
def add_book_to_library(self, book_path:str) -> None:

0 commit comments

Comments
 (0)