1616 *
1717 */
1818
19- use std:: sync:: Arc ;
20-
21- use chrono:: { DateTime , Local , NaiveDateTime , NaiveTime , Utc } ;
22- use relative_path:: RelativePathBuf ;
19+ use std:: { io:: ErrorKind , sync:: Arc } ;
2320
2421use crate :: {
2522 catalog:: manifest:: Manifest ,
2623 query:: PartialTimeFilter ,
27- storage:: { ObjectStorage , ObjectStorageError , MANIFEST_FILE } ,
28- utils:: get_url,
24+ storage:: { object_storage:: manifest_path, ObjectStorage , ObjectStorageError } ,
2925} ;
26+ use chrono:: { DateTime , Local , NaiveDateTime , NaiveTime , Utc } ;
27+ use relative_path:: RelativePathBuf ;
28+ use std:: io:: Error as IOError ;
3029
3130use self :: { column:: Column , snapshot:: ManifestItem } ;
3231
@@ -117,13 +116,7 @@ pub async fn update_snapshot(
117116
118117 let mut ch = false ;
119118 for m in manifests. iter ( ) {
120- let s = get_url ( ) ;
121- let p = format ! (
122- "{}.{}.{}" ,
123- s. domain( ) . unwrap( ) ,
124- s. port( ) . unwrap_or_default( ) ,
125- MANIFEST_FILE
126- ) ;
119+ let p = manifest_path ( "" ) . to_string ( ) ;
127120 if m. manifest_path . contains ( & p) {
128121 ch = true ;
129122 }
@@ -147,7 +140,11 @@ pub async fn update_snapshot(
147140 23 * 3600 + 59 * 60 + 59 ,
148141 999_999_999 ,
149142 )
150- . unwrap ( ) ,
143+ . ok_or ( IOError :: new (
144+ ErrorKind :: Other ,
145+ "Failed to create upper bound for manifest" ,
146+ ) )
147+ . map_err ( ObjectStorageError :: IoError ) ?,
151148 )
152149 . and_utc ( ) ;
153150
@@ -156,17 +153,11 @@ pub async fn update_snapshot(
156153 ..Manifest :: default ( )
157154 } ;
158155
159- let addr = get_url ( ) ;
160- let mainfest_file_name = format ! (
161- "{}.{}.{}" ,
162- addr. domain( ) . unwrap( ) ,
163- addr. port( ) . unwrap_or_default( ) ,
164- MANIFEST_FILE
165- ) ;
156+ let mainfest_file_name = manifest_path ( "" ) . to_string ( ) ;
166157 let path =
167158 partition_path ( stream_name, lower_bound, upper_bound) . join ( & mainfest_file_name) ;
168159 storage
169- . put_object ( & path, serde_json:: to_vec ( & manifest) . unwrap ( ) . into ( ) )
160+ . put_object ( & path, serde_json:: to_vec ( & manifest) ? . into ( ) )
170161 . await ?;
171162 let path = storage. absolute_url ( & path) ;
172163 let new_snapshot_entriy = snapshot:: ManifestItem {
@@ -195,13 +186,7 @@ pub async fn update_snapshot(
195186 ..Manifest :: default ( )
196187 } ;
197188
198- let addr = get_url ( ) ;
199- let mainfest_file_name = format ! (
200- "{}.{}.{}" ,
201- addr. domain( ) . unwrap( ) ,
202- addr. port( ) . unwrap( ) ,
203- MANIFEST_FILE
204- ) ;
189+ let mainfest_file_name = manifest_path ( "" ) . to_string ( ) ;
205190 let path = partition_path ( stream_name, lower_bound, upper_bound) . join ( & mainfest_file_name) ;
206191 storage
207192 . put_object ( & path, serde_json:: to_vec ( & manifest) . unwrap ( ) . into ( ) )
0 commit comments