Skip to content

Commit 995d5f8

Browse files
committed
fix file removal logic
Signed-off-by: Lance-Drane <[email protected]>
1 parent 563d678 commit 995d5f8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

ipsframework/jupyter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def remove_last_data_file_from_notebook(dest: str, index: Optional[int] = None)
166166
if end_char == '\n':
167167
# each entry gets its own "line", so we don't need to search anymore
168168
break
169-
if end_char == "'" and ips_cell[end_index] == ',':
169+
if ips_cell[end_index] == "'" and ips_cell[end_index - 1] != '\\':
170170
# we have found the name of the file
171171
ret = ips_cell[file_name_start_index:end_index]
172172
except IndexError:

ipsframework/services.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,10 @@ def add_data_file_to_notebook(self, data_file_path: str, timestamp: float, noteb
19711971
if filename_to_remove is not None:
19721972
# now remove the state file from the filesystem
19731973
file_to_remove = os.path.join(self._jupyterhub_dir, 'data', filename_to_remove)
1974-
shutil.rmtree(file_to_remove, ignore_errors=True)
1974+
try:
1975+
os.remove(file_to_remove)
1976+
except FileNotFoundError:
1977+
pass
19751978

19761979
# add newest data file to notebook
19771980
add_data_file_to_notebook(f'{self._jupyterhub_dir}{notebook_name}', data_file_name, index)

0 commit comments

Comments
 (0)