Upload the raw bytes of a local segment file to the object store at `object_path`.
(
cold: &crate::storage::cold::ColdStorage,
local_path: &std::path::Path,
object_path: &str,
)
| 172 | |
| 173 | /// Upload the raw bytes of a local segment file to the object store at `object_path`. |
| 174 | async fn upload_raw_segment( |
| 175 | cold: &crate::storage::cold::ColdStorage, |
| 176 | local_path: &std::path::Path, |
| 177 | object_path: &str, |
| 178 | ) -> crate::Result<()> { |
| 179 | let path_buf = local_path.to_path_buf(); |
| 180 | let data = tokio::task::spawn_blocking(move || std::fs::read(&path_buf)) |
| 181 | .await |
| 182 | .map_err(|e| crate::Error::Internal { |
| 183 | detail: format!("spawn_blocking join: {e}"), |
| 184 | })? |
| 185 | .map_err(|e| crate::Error::Internal { |
| 186 | detail: format!("read segment file: {e}"), |
| 187 | })?; |
| 188 | |
| 189 | let store = cold.object_store(); |
| 190 | let opath = object_store::path::Path::from(object_path.to_owned()); |
| 191 | |
| 192 | store |
| 193 | .put_opts( |
| 194 | &opath, |
| 195 | object_store::PutPayload::from(data), |
| 196 | object_store::PutOptions::default(), |
| 197 | ) |
| 198 | .await |
| 199 | .map_err(|e| crate::Error::Internal { |
| 200 | detail: format!("object store put: {e}"), |
| 201 | })?; |
| 202 | |
| 203 | Ok(()) |
| 204 | } |
| 205 | |
| 206 | /// Read a directory on a blocking thread, returning paths of all regular files. |
| 207 | async fn read_dir_sync(dir: &std::path::Path) -> std::io::Result<Vec<PathBuf>> { |
no test coverage detected