File tree Expand file tree Collapse file tree
pages/api/v1/repositories/[slug] Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ SSH_SERVER_PORT_LAN=
3535# Disable the DELETE feature
3636# DISABLE_DELETE_REPO=true
3737
38+ # Do not allow to remove append-only mode, once set
39+ # DISABLE_REVERT_APPEND_ONLY=true
40+
3841# Disable the integrations (API tokens to CRUD repositories)
3942# DISABLE_INTEGRATIONS=true
4043
@@ -50,4 +53,4 @@ MAIL_SMTP_PWD=
5053MAIL_REJECT_SELFSIGNED_TLS =
5154
5255# Force app to start on IPv6
53- # HOSTNAME=::
56+ # HOSTNAME=::
Original file line number Diff line number Diff line change @@ -221,10 +221,18 @@ export default function RepoManage(props: RepoManageProps) {
221221 ) ;
222222 router . replace ( '/' ) ;
223223 } else {
224- const errorMessage = await response . json ( ) ;
225- toast . error ( `An error has occurred : ${ errorMessage . message . stderr } ` , toastOptions ) ;
226- router . replace ( '/' ) ;
227- console . log ( `Fail to ${ props . mode } ` ) ;
224+ if ( response . status == 403 ) {
225+ toast . warning (
226+ '🔒 The server is currently protected against reverting append-only mode.' ,
227+ toastOptions
228+ ) ;
229+ router . replace ( '/' ) ;
230+ } else {
231+ const errorMessage = await response . json ( ) ;
232+ toast . error ( `An error has occurred : ${ errorMessage . message . stderr } ` , toastOptions ) ;
233+ router . replace ( '/' ) ;
234+ console . log ( `Fail to ${ props . mode } ` ) ;
235+ }
228236 }
229237 } )
230238 . catch ( ( error ) => {
Original file line number Diff line number Diff line change @@ -94,6 +94,15 @@ export default async function handler(
9494 'The SSH key is already used in another repository. Please use another key or delete the key from the other repository.' ,
9595 } ) ;
9696 }
97+ if ( repo . appendOnlyMode && appendOnlyMode === false ) {
98+ if ( process . env . DISABLE_REVERT_APPEND_ONLY === "true" ) {
99+ res . status ( 403 ) . json ( {
100+ status : 403 ,
101+ message : 'Reverting Append-Only mode is disabled on this server' ,
102+ } ) ;
103+ return ;
104+ }
105+ }
97106
98107 const updatedRepo : Repository = {
99108 ...repo ,
You can’t perform that action at this time.
0 commit comments