| 1858 | } |
| 1859 | |
| 1860 | Future<> CloseAsync() override { |
| 1861 | if (closed_) return Status::OK(); |
| 1862 | |
| 1863 | RETURN_NOT_OK(CleanupIfFailed(EnsureReadyToFlushFromClose())); |
| 1864 | |
| 1865 | // Wait for in-progress uploads to finish (if async writes are enabled) |
| 1866 | return FlushAsync().Then([self = Self()]() { |
| 1867 | if (self->IsMultipartCreated()) { |
| 1868 | RETURN_NOT_OK(self->CleanupIfFailed(self->FinishPartUploadAfterFlush())); |
| 1869 | } |
| 1870 | return self->CleanupAfterClose(); |
| 1871 | }); |
| 1872 | } |
| 1873 | |
| 1874 | bool closed() const override { return closed_; } |
| 1875 | |