@@ -14,7 +14,7 @@ use crate::{
1414 } ,
1515 ops:: pointed_snapshots,
1616 refs:: { Ref , RefError , delete_branch, delete_tag, list_refs} ,
17- repository:: RepositoryError ,
17+ repository:: { RepositoryError , RepositoryErrorKind } ,
1818 storage:: { self , DeleteObjectsResult , ListInfo } ,
1919} ;
2020
@@ -160,6 +160,13 @@ pub async fn garbage_collect(
160160 asset_manager : Arc < AssetManager > ,
161161 config : & GCConfig ,
162162) -> GCResult < GCSummary > {
163+ if !storage. can_write ( ) {
164+ return Err ( GCError :: Repository (
165+ RepositoryErrorKind :: ReadonlyStorage ( "Cannot garbage collect" . to_string ( ) )
166+ . into ( ) ,
167+ ) ) ;
168+ }
169+
163170 // TODO: this function could have much more parallelism
164171 if !config. action_needed ( ) {
165172 tracing:: info!( "No action requested" ) ;
@@ -543,6 +550,13 @@ pub async fn expire(
543550 expired_branches : ExpiredRefAction ,
544551 expired_tags : ExpiredRefAction ,
545552) -> GCResult < ExpireResult > {
553+ if !storage. can_write ( ) {
554+ return Err ( GCError :: Repository (
555+ RepositoryErrorKind :: ReadonlyStorage ( "Cannot expire snapshots" . to_string ( ) )
556+ . into ( ) ,
557+ ) ) ;
558+ }
559+
546560 let all_refs = stream:: iter ( list_refs ( storage, storage_settings) . await ?) ;
547561 let asset_manager = Arc :: clone ( & asset_manager. clone ( ) ) ;
548562
0 commit comments