| 31 | TErrorCode::GENERAL, "DiskFile::Delete() failed with incorrect status")); |
| 32 | |
| 33 | Status DiskFile::Delete(const unique_lock<shared_mutex>& lock) { |
| 34 | DCHECK(lock.mutex() == &physical_file_lock_ && lock.owns_lock()); |
| 35 | Status status = Status::OK(); |
| 36 | unique_lock<SpinLock> status_l(status_lock_); |
| 37 | // No support for remote file deletion yet. |
| 38 | if (disk_type_ == DiskFileType::LOCAL_BUFFER || disk_type_ == DiskFileType::LOCAL) { |
| 39 | if (is_deleted(status_l)) return DISK_FILE_DELETE_FAILED_INCORRECT_STATUS; |
| 40 | if (file_writer_ != nullptr) { |
| 41 | // Close the file writer to release the file handle. |
| 42 | RETURN_IF_ERROR(file_writer_->Close()); |
| 43 | } |
| 44 | // Remove the local physical file if it exists. |
| 45 | RETURN_IF_ERROR(FileSystemUtil::RemovePaths({path_})); |
| 46 | SetStatusLocked(io::DiskFileStatus::DELETED, status_l); |
| 47 | } |
| 48 | return status; |
| 49 | } |
| 50 | |
| 51 | DiskFile::DiskFile(const string& path, DiskIoMgr* io_mgr) |
| 52 | : path_(path), |