5353from scripts .approve_registrations import approve_past_pendings
5454
5555from website import settings , search
56+ from website .archiver .tasks import force_archive
5657
5758
5859class NodeMixin (PermissionRequiredMixin ):
@@ -705,6 +706,12 @@ class NodeReindexShare(NodeMixin, View):
705706 def post (self , request , * args , ** kwargs ):
706707 node = self .get_object ()
707708 update_share (node )
709+ messages .success (
710+ request ,
711+ 'Reindex request has been sent to SHARE. '
712+ 'Changes typically appear in OSF Search within about 5 minutes, '
713+ 'subject to background queue load and SHARE availability.'
714+ )
708715 update_admin_log (
709716 user_id = self .request .user .id ,
710717 object_id = node ._id ,
@@ -830,16 +837,20 @@ class CheckArchiveStatusRegistrationsView(NodeMixin, View):
830837
831838 def get (self , request , * args , ** kwargs ):
832839 # Prevents circular imports that cause admin app to hang at startup
833- from osf .management .commands .force_archive import check
840+ from osf .management .commands .force_archive import check , DEFAULT_PERMISSIBLE_ADDONS
834841
835842 registration = self .get_object ()
836843
837844 if registration .archived :
838845 messages .success (request , f"Registration { registration ._id } is archived." )
839846 return redirect (self .get_success_url ())
840847
848+ addons = set (DEFAULT_PERMISSIBLE_ADDONS )
849+ for reg in registration .node_and_primary_descendants ():
850+ addons .update (reg .registered_from .get_addon_names ())
851+
841852 try :
842- archive_status = check (registration )
853+ archive_status = check (registration , permissible_addons = addons , verify_addons = False )
843854 messages .success (request , archive_status )
844855 except RegistrationStuckError as exc :
845856 messages .error (request , str (exc ))
@@ -860,7 +871,7 @@ class ForceArchiveRegistrationsView(NodeMixin, View):
860871
861872 def post (self , request , * args , ** kwargs ):
862873 # Prevents circular imports that cause admin app to hang at startup
863- from osf .management .commands .force_archive import verify , archive , DEFAULT_PERMISSIBLE_ADDONS
874+ from osf .management .commands .force_archive import verify , DEFAULT_PERMISSIBLE_ADDONS
864875
865876 registration = self .get_object ()
866877 force_archive_params = request .POST
@@ -871,32 +882,33 @@ def post(self, request, *args, **kwargs):
871882
872883 allow_unconfigured = force_archive_params .get ('allow_unconfigured' , False )
873884
874- addons = set (registration .registered_from .get_addon_names ())
875- addons .update (DEFAULT_PERMISSIBLE_ADDONS )
885+ addons = set (DEFAULT_PERMISSIBLE_ADDONS )
886+ for reg in registration .node_and_primary_descendants ():
887+ addons .update (reg .registered_from .get_addon_names ())
876888
877- try :
878- verify (registration , permissible_addons = addons , raise_error = True )
879- except ValidationError as exc :
880- messages .error (request , str (exc ))
881- return redirect (self .get_success_url ())
889+ # No need to verify addons during force archive,
890+ # because we fetched all permissible addons above
891+ verify_addons = False
882892
883- dry_mode = force_archive_params .get ('dry_mode' , False )
884-
885- if dry_mode :
886- messages .success (request , f"Registration { registration ._id } can be archived." )
887- else :
893+ if force_archive_params .get ('dry_mode' , False ):
894+ # For dry mode, verify synchronously to provide immediate feedback
888895 try :
889- archive (
890- registration ,
891- permissible_addons = addons ,
892- allow_unconfigured = allow_unconfigured ,
893- skip_collisions = skip_collision ,
894- delete_collisions = delete_collision ,
895- )
896- messages .success (request , 'Registration archive process has finished.' )
897- except Exception as exc :
898- messages .error (request , f'This registration cannot be archived due to { exc .__class__ .__name__ } : { str (exc )} . '
899- f'If the problem persists get a developer to fix it.' )
896+ verify (registration , permissible_addons = addons , verify_addons = verify_addons , raise_error = True )
897+ messages .success (request , f"Registration { registration ._id } can be archived." )
898+ except ValidationError as exc :
899+ messages .error (request , str (exc ))
900+ return redirect (self .get_success_url ())
901+ else :
902+ # For actual archiving, skip synchronous verification to avoid 502 timeouts
903+ # Verification will be performed asynchronously in the task
904+ force_archive_task = force_archive .delay (
905+ str (registration ._id ),
906+ permissible_addons = list (addons ),
907+ allow_unconfigured = allow_unconfigured ,
908+ skip_collisions = skip_collision ,
909+ delete_collisions = delete_collision ,
910+ )
911+ messages .success (request , f'Registration archive process has started. Task id: { force_archive_task .id } .' )
900912
901913 return redirect (self .get_success_url ())
902914
0 commit comments