From 824cd9abf5027eaca6013da4003916a1c31d6643 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Wed, 8 Nov 2023 16:06:44 +0000 Subject: [PATCH] Revert "half-baked copy_file impl" This reverts commit f5a5f0bce8e968f4f00c2b7bc53ad5817b1a14ac. --- libs/remote_storage/src/azure_blob.rs | 4 ---- libs/remote_storage/src/lib.rs | 13 +----------- libs/remote_storage/src/local_fs.rs | 21 -------------------- libs/remote_storage/src/s3_bucket.rs | 9 --------- libs/remote_storage/src/simulate_failures.rs | 4 ---- 5 files changed, 1 insertion(+), 50 deletions(-) diff --git a/libs/remote_storage/src/azure_blob.rs b/libs/remote_storage/src/azure_blob.rs index 119d4c9e55..152929ecd3 100644 --- a/libs/remote_storage/src/azure_blob.rs +++ b/libs/remote_storage/src/azure_blob.rs @@ -353,8 +353,4 @@ impl RemoteStorage for AzureBlobStorage { } Ok(()) } - - async fn copy_object(&self, src: &RemotePath, dst: &RemotePath) -> anyhow::Result<()> { - unimplemented!() - } } diff --git a/libs/remote_storage/src/lib.rs b/libs/remote_storage/src/lib.rs index bd8ead4566..435364d83a 100644 --- a/libs/remote_storage/src/lib.rs +++ b/libs/remote_storage/src/lib.rs @@ -112,7 +112,7 @@ impl RemotePath { self.0.file_name() } - pub fn join>(&self, segment: P) -> Self { + pub fn join(&self, segment: &Utf8Path) -> Self { Self(self.0.join(segment)) } @@ -183,8 +183,6 @@ pub trait RemoteStorage: Send + Sync + 'static { async fn delete(&self, path: &RemotePath) -> anyhow::Result<()>; async fn delete_objects<'a>(&self, paths: &'a [RemotePath]) -> anyhow::Result<()>; - - async fn copy_object(&self, src: &RemotePath, dst: &RemotePath) -> anyhow::Result<()>; } pub struct Download { @@ -330,15 +328,6 @@ impl GenericRemoteStorage { Self::Unreliable(s) => s.delete_objects(paths).await, } } - - pub async fn copy_object(&self, src: &RemotePath, dst: &RemotePath) -> anyhow::Result<()> { - match self { - Self::LocalFs(s) => s.copy_object(src, dst).await, - Self::AwsS3(s) => s.copy_object(src, dst).await, - Self::AzureBlob(s) => s.copy_object(src, dst).await, - Self::Unreliable(s) => s.copy_object(src, dst).await, - } - } } impl GenericRemoteStorage { diff --git a/libs/remote_storage/src/local_fs.rs b/libs/remote_storage/src/local_fs.rs index f224b78fcd..3d32b6b631 100644 --- a/libs/remote_storage/src/local_fs.rs +++ b/libs/remote_storage/src/local_fs.rs @@ -371,27 +371,6 @@ impl RemoteStorage for LocalFs { } Ok(()) } - - async fn copy_object(&self, src: &RemotePath, dst: &RemotePath) -> anyhow::Result<()> { - let src_path = src.with_base(&self.storage_root); - let dst_path = dst.with_base(&self.storage_root); - - // If the destination file already exists, we need to delete it first. - if dst_path.exists() { - fs::remove_file(&dst_path).await?; - } - - // Copy the file. - fs::copy(&src_path, &dst_path).await?; - - // Copy the metadata. - let metadata_path = storage_metadata_path(&src_path); - if metadata_path.exists() { - fs::copy(&metadata_path, storage_metadata_path(&dst_path)).await?; - } - - Ok(()) - } } fn storage_metadata_path(original_path: &Utf8Path) -> Utf8PathBuf { diff --git a/libs/remote_storage/src/s3_bucket.rs b/libs/remote_storage/src/s3_bucket.rs index d78b6f46cf..fc94281666 100644 --- a/libs/remote_storage/src/s3_bucket.rs +++ b/libs/remote_storage/src/s3_bucket.rs @@ -221,8 +221,6 @@ impl S3Bucket { )), } } - - } pin_project_lite::pin_project! { @@ -548,11 +546,6 @@ impl RemoteStorage for S3Bucket { let paths = std::array::from_ref(path); self.delete_objects(paths).await } - - async fn copy_object(&self, src: &RemotePath, dst: &RemotePath) -> anyhow::Result<()> { - unimplemented!() - } - } /// On drop (cancellation) count towards [`metrics::BucketMetrics::cancelled_waits`]. @@ -635,6 +628,4 @@ mod tests { } } } - - } diff --git a/libs/remote_storage/src/simulate_failures.rs b/libs/remote_storage/src/simulate_failures.rs index 7e60aa5f34..6d6a5c1d24 100644 --- a/libs/remote_storage/src/simulate_failures.rs +++ b/libs/remote_storage/src/simulate_failures.rs @@ -149,8 +149,4 @@ impl RemoteStorage for UnreliableWrapper { } Ok(()) } - - async fn copy_object(&self, src: &RemotePath, dst: &RemotePath) -> anyhow::Result<()> { - unimplemented!() - } }