Avoid the while loop
This commit is contained in:
1 parent
8c465f0afe
commit
844fce3c90
1 file changed
+1
-2
@@ -40,9 +40,8 @@ def source_pre_save(sender, instance, **kwargs):
|
|||||||
# the names in the relative path are also in the absolute path
|
# the names in the relative path are also in the absolute path
|
||||||
parents_count = len(ad_parents_set.intersection(rd_parents_set))
|
parents_count = len(ad_parents_set.intersection(rd_parents_set))
|
||||||
work_directory = existing_dirpath
|
work_directory = existing_dirpath
|
||||||
while parents_count > 0:
|
for _ in range(parents_count, 0, -1):
|
||||||
work_directory = work_directory.parent
|
work_directory = work_directory.parent
|
||||||
parents_count -= 1
|
|
||||||
with TemporaryDirectory(suffix='.'+new_dirpath.name, prefix='.tmp.', dir=work_directory) as tmp_dir:
|
with TemporaryDirectory(suffix='.'+new_dirpath.name, prefix='.tmp.', dir=work_directory) as tmp_dir:
|
||||||
tmp_dirpath = Path(tmp_dir)
|
tmp_dirpath = Path(tmp_dir)
|
||||||
existed = None
|
existed = None
|
||||||
|
|||||||
Reference in new issue
Block a user