@@ -42,11 +42,11 @@ def validate_storage_type(output_config: ArchiveOutput, storage_engine: str) ->
4242def get_expiry_epoch_secs (retention_minutes : int ) -> int :
4343 """
4444 Returns a cutoff `expiry_epoch` based on the current timestamp and `retention_minutes`. Any
45- target with a timestamp (`ts`) less than `expiry_epoch` are considered expired.
45+ candidate with a timestamp (`ts`) less than `expiry_epoch` is considered expired.
4646 The `expiry_epoch` is calculated as `expiry_epoch = cur_time - retention_secs`.
4747
48- :param: retention_minutes: Retention period in minutes.
49- :return: The UTC epoch of the expiry time.
48+ :param retention_minutes: Retention period in minutes.
49+ :return: The UTC epoch representing the expiry cutoff time.
5050 """
5151 return int (time .time () - retention_minutes * MIN_TO_SECONDS )
5252
@@ -55,16 +55,16 @@ def get_oid_with_expiry_time(expiry_epoch_secs: int) -> ObjectId:
5555 return ObjectId .from_datetime (datetime .fromtimestamp (expiry_epoch_secs , tz = timezone .utc ))
5656
5757
58- def execute_fs_deletion (fs_storage_config : FsStorage , deletion_candidate : str ) -> None :
58+ def execute_fs_deletion (fs_storage_config : FsStorage , candidate : str ) -> None :
5959 """
60- Deletes a target (either a directory or a file) from the filesystem storage. The full path
61- of the target is constructed as `fs_storage_config.directory / target `. The function performs
62- no action if the target does not exist.
60+ Deletes a candidate (either a directory or a file) from the filesystem storage. The full path
61+ of the candidate is constructed as `fs_storage_config.directory / candidate `. The function
62+ performs no action if the candidate does not exist.
6363
6464 :param fs_storage_config:
65- :param deletion_candidate : Relative path of the file or directory to delete.
65+ :param candidate : Relative path of the file or directory to delete.
6666 """
67- path_to_delete = fs_storage_config .directory / deletion_candidate
67+ path_to_delete = fs_storage_config .directory / candidate
6868 if not path_to_delete .exists ():
6969 return
7070
@@ -81,8 +81,8 @@ def execute_deletion(output_config: ArchiveOutput, deletion_candidates: Set[str]
8181 if StorageType .S3 == storage_type :
8282 s3_delete_objects (storage_config .s3_config , deletion_candidates )
8383 elif StorageType .FS == storage_type :
84- for target in deletion_candidates :
85- execute_fs_deletion (storage_config , target )
84+ for candidate in deletion_candidates :
85+ execute_fs_deletion (storage_config , candidate )
8686 else :
8787 raise ValueError (f"Unsupported Storage type: { storage_type } " )
8888
@@ -115,24 +115,26 @@ def __init__(self, recovery_file_path: pathlib.Path):
115115 for line in f :
116116 self ._candidates .add (line .strip ())
117117
118- def add_candidate (self , target : str ) -> None :
119- if target not in self ._candidates :
120- self ._candidates .add (target )
121- self ._candidates_to_persist .append (target )
118+ def add_candidate (self , candidate : str ) -> None :
119+ if candidate not in self ._candidates :
120+ self ._candidates .add (candidate )
121+ self ._candidates_to_persist .append (candidate )
122122
123123 def get_candidates (self ) -> Set [str ]:
124124 return self ._candidates
125125
126126 def persist_new_candidates (self ) -> None :
127127 """
128- Writes any new candidates added since initialization to the recovery file.
128+ Writes any new candidates from `_candidates_to_persist` to the recovery file and clears
129+ the buffer.
130+ The method returns immediately without writing if `_candidates_to_persist` is empty.
129131 """
130132 if len (self ._candidates_to_persist ) == 0 :
131133 return
132134
133135 with open (self ._recovery_file_path , "a" ) as f :
134- for target in self ._candidates_to_persist :
135- f .write (f"{ target } \n " )
136+ for candidate in self ._candidates_to_persist :
137+ f .write (f"{ candidate } \n " )
136138
137139 self ._candidates_to_persist .clear ()
138140
0 commit comments