@@ -95,19 +95,6 @@ def __init__(self, organizer: mobase.IOrganizer):
9595 self .processedBasenames : set [str ] = set () # Track already-grouped files
9696 self .category_groups : dict [str , list [mobase .FileTreeEntry ]] = {}
9797
98- def moveOverwriteMerge (self , source : str , destination : str ):
99- if not os .path .exists (destination ):
100- shutil .move (source , destination )
101- return
102- if os .path .isfile (source ):
103- os .replace (source , destination )
104- return
105- for item in os .listdir (source ):
106- s_item = os .path .join (source , item )
107- d_item = os .path .join (destination , item )
108- self .moveOverwriteMerge (s_item , d_item )
109- os .rmdir (source )
110-
11198 def sanitizeFolderName (self , name : str ) -> str :
11299 invalid_chars = '+&<>:"|?*\\ /'
113100 for char in invalid_chars :
@@ -164,18 +151,19 @@ def moveTreeContent(
164151 targettree .move (entry , destination , mobase .IFileTree .MERGE )
165152 elif installtype == "os" :
166153 entry = entries [0 ]
167- for subentry in entry :
168- mod_file = subentry .name ()
169- mod_name_val = entry .name ()
170- mod_path = os .path .join (self .organizer .modsPath (), mod_name_val )
171- insideMods = os .path .join (mod_path , destination )
172- os .makedirs (insideMods , exist_ok = True )
173- src = os .path .join (mod_path , mod_file )
174- dst = os .path .join (mod_path , destination , mod_file )
175- shutil .move (
176- src ,
177- dst ,
178- )
154+ if isinstance (entry , mobase .IFileTree ):
155+ for subentry in entry :
156+ mod_file = subentry .name ()
157+ mod_name_val = entry .name ()
158+ mod_path = os .path .join (self .organizer .modsPath (), mod_name_val )
159+ insideMods = os .path .join (mod_path , destination )
160+ os .makedirs (insideMods , exist_ok = True )
161+ src = os .path .join (mod_path , mod_file )
162+ dst = os .path .join (mod_path , destination , mod_file )
163+ shutil .move (
164+ src ,
165+ dst ,
166+ )
179167 return None
180168
181169 def addModDetectionCandidate (
@@ -221,12 +209,12 @@ def showModDetectionDialog(self) -> set[int] | None:
221209 selectButtons = QHBoxLayout ()
222210 selectAllButton = QPushButton ("Select All" )
223211 selectNoneButton = QPushButton ("Select None" )
224- selectAllButton .clicked .connect (
212+ selectAllButton .clicked .connect ( # type: ignore # type: ignore
225213 lambda : self .setDialogSelection (listWidget , True )
226- ) # type: ignore
227- selectNoneButton .clicked .connect (
214+ )
215+ selectNoneButton .clicked .connect ( # type: ignore # type: ignore
228216 lambda : self .setDialogSelection (listWidget , False )
229- ) # type: ignore
217+ )
230218 selectButtons .addWidget (selectAllButton )
231219 selectButtons .addWidget (selectNoneButton )
232220 layout .addLayout (selectButtons )
@@ -348,9 +336,9 @@ def collectModCandidates(
348336 candidate_entries = entries
349337
350338 if category == "Root" :
351- candidate_entries = []
339+ candidate_entries : list [ mobase . FileTreeEntry ] = []
352340 for root_entry in entries :
353- if root_entry .isDir ():
341+ if isinstance ( root_entry , mobase . IFileTree ) and root_entry .isDir ():
354342 candidate_entries .extend (list (root_entry ))
355343 else :
356344 candidate_entries .append (root_entry )
0 commit comments