Rename to a temporary path then final destination

Fixes #798
This commit is contained in:
tcely 2025-02-28 20:45:21 -05:00 committed by GitHub
parent 20e879767c
commit f41faa444d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -34,8 +34,10 @@ def source_pre_save(sender, instance, **kwargs):
not new_dirpath.exists()
)
if rename_source_directory:
tmp_dirpath = existing_dirpath.parent / ('.tmp.' + existing_dirpath.name)
existing_dirpath.rename(tmp_dirpath)
mkdir_p(new_dirpath.parent)
existing_dirpath.rename(new_dirpath)
tmp_dirpath.rename(new_dirpath)
recreate_index_source_task = (
existing_source.name != instance.name or
existing_source.index_schedule != instance.index_schedule