| 3251 | } |
| 3252 | |
| 3253 | Status CopyFile(const AzureLocation& src, const AzureLocation& dest) { |
| 3254 | RETURN_NOT_OK(ValidateFileLocation(src)); |
| 3255 | RETURN_NOT_OK(ValidateFileLocation(dest)); |
| 3256 | if (src == dest) { |
| 3257 | return Status::OK(); |
| 3258 | } |
| 3259 | auto src_url = GetBlobClient(src.container, src.path).GetUrl(); |
| 3260 | auto dest_blob_client = GetBlobClient(dest.container, dest.path); |
| 3261 | if (!dest.path.empty()) { |
| 3262 | auto dest_parent = dest.parent(); |
| 3263 | if (!dest_parent.path.empty()) { |
| 3264 | auto dest_container_client = GetBlobContainerClient(dest_parent.container); |
| 3265 | ARROW_ASSIGN_OR_RAISE(auto info, GetFileInfo(dest_container_client, dest_parent)); |
| 3266 | if (info.type() == FileType::File) { |
| 3267 | return NotADir(dest_parent); |
| 3268 | } |
| 3269 | } |
| 3270 | } |
| 3271 | try { |
| 3272 | // We use StartCopyFromUri instead of CopyFromUri because it supports blobs larger |
| 3273 | // than 256 MiB and it doesn't require generating a SAS token to authenticate |
| 3274 | // reading a source blob in the same storage account. |
| 3275 | auto copy_operation = dest_blob_client.StartCopyFromUri(src_url); |
| 3276 | // For large blobs, the copy operation may be slow so we need to poll until it |
| 3277 | // completes. We use a polling interval of 1 second. |
| 3278 | copy_operation.PollUntilDone(std::chrono::milliseconds(1000)); |
| 3279 | } catch (const Storage::StorageException& exception) { |
| 3280 | // StartCopyFromUri failed or a GetProperties call inside PollUntilDone failed. |
| 3281 | return ExceptionToStatus( |
| 3282 | exception, "Failed to start blob copy or poll status of ongoing copy. (", |
| 3283 | src_url, " -> ", dest_blob_client.GetUrl(), ")"); |
| 3284 | } catch (const Azure::Core::RequestFailedException& exception) { |
| 3285 | // A GetProperties call inside PollUntilDone returned a failed CopyStatus. |
| 3286 | return ExceptionToStatus(exception, "Failed to copy blob. (", src_url, " -> ", |
| 3287 | dest_blob_client.GetUrl(), ")"); |
| 3288 | } |
| 3289 | return Status::OK(); |
| 3290 | } |
| 3291 | }; |
| 3292 | |
| 3293 | std::atomic<LeaseGuard::SteadyClock::time_point> LeaseGuard::latest_known_expiry_time_ = |
no test coverage detected