handle edge cases in migration clean up

This commit is contained in:
Simon 2023-07-28 17:56:28 +07:00
parent 6f915a5733
commit ab8fed14bb
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 5 additions and 1 deletions

View File

@ -2,6 +2,7 @@
import json
import os
import shutil
from django.core.management.base import BaseCommand
from home.src.es.connect import ElasticWrap, IndexPaginate
@ -167,5 +168,8 @@ class FolderMigration:
all_folders = ignore_filelist(os.listdir(self.videos))
for folder in all_folders:
folder_path = os.path.join(self.videos, folder)
if not os.path.isdir(folder_path):
continue
if not ignore_filelist(os.listdir(folder_path)):
os.rmdir(folder_path)
shutil.rmtree(folder_path)