@@ -251,8 +251,8 @@ def _load_challenge_id(self):
251
251
raise RemoteChallengeNotFound (f"Could not load remote challenge with name '{ self ['name' ]} '" )
252
252
253
253
def _validate_files (self ):
254
- # if the challenge defines files, make sure they exist before making any changes to the challenge
255
- for challenge_file in self . get ( " files" ) or [] :
254
+ files = self . get ( " files" ) or []
255
+ for challenge_file in files :
256
256
if not (self .challenge_directory / challenge_file ).exists ():
257
257
raise InvalidChallengeFile (f"File { challenge_file } could not be loaded" )
258
258
@@ -364,7 +364,9 @@ def _create_file(self, local_path: Path):
364
364
365
365
def _create_all_files (self ):
366
366
new_files = []
367
- for challenge_file in self .get ("files" ) or []:
367
+
368
+ files = self .get ("files" ) or []
369
+ for challenge_file in files :
368
370
new_files .append (("file" , open (self .challenge_directory / challenge_file , mode = "rb" )))
369
371
370
372
files_payload = {"challenge_id" : self .challenge_id , "type" : "challenge" }
@@ -587,9 +589,12 @@ def sync(self, ignore: Tuple[str] = ()) -> None:
587
589
588
590
# Create / Upload files
589
591
if "files" not in ignore :
592
+ self ["files" ] = self .get ("files" ) or []
593
+ remote_challenge ["files" ] = remote_challenge .get ("files" ) or []
594
+
590
595
# Get basenames of local files to compare against remote files
591
- local_files = {f .split ("/" )[- 1 ]: f for f in self . get ( "files" ) or [ ]}
592
- remote_files = self ._normalize_remote_files (remote_challenge . get ( "files" ) or [ ])
596
+ local_files = {f .split ("/" )[- 1 ]: f for f in self [ "files" ]}
597
+ remote_files = self ._normalize_remote_files (remote_challenge [ "files" ])
593
598
594
599
# Delete remote files which are no longer defined locally
595
600
for remote_file in remote_files :
0 commit comments