File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ error_code DiskStorage::Open(string_view path) {
7474 if (absl::GetFlag (FLAGS_backing_file_direct))
7575 kFlags |= O_DIRECT;
7676
77+ backing_file_path_ = path;
7778 auto res = OpenLinux (path, kFlags , 0666 );
7879 if (!res)
7980 return res.error ();
@@ -104,8 +105,13 @@ void DiskStorage::Close() {
104105 while (pending_ops_ > 0 || grow_.pending )
105106 util::ThisFiber::SleepFor (10ms);
106107
107- backing_file_->Close ();
108+ auto ec = backing_file_->Close ();
109+ LOG_IF (ERROR, ec) << " Failed to close backing file: " << ec;
108110 backing_file_.reset ();
111+
112+ int errc = unlink (backing_file_path_.c_str ());
113+ LOG_IF (ERROR, errc != 0 ) << " Failed to unlink backing file: "
114+ << std::error_code{errc, std::system_category ()};
109115}
110116
111117void DiskStorage::Read (DiskSegment segment, ReadCb cb) {
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ class DiskStorage {
7070 util::fb2::EventCount ev; // woken up when in-progress op finishes
7171 } grow_; // status of latest blocking Grow() operation
7272
73+ std::string backing_file_path_;
7374 std::unique_ptr<util::fb2::LinuxFile> backing_file_;
7475 ExternalAllocator alloc_;
7576};
Original file line number Diff line number Diff line change @@ -32,7 +32,9 @@ struct DiskStorageTest : public PoolTestBase {
3232 void Close () {
3333 storage_->Close ();
3434 storage_.reset ();
35- unlink (filename_.c_str ());
35+
36+ // Disk storage deletes its files on exit
37+ EXPECT_FALSE (std::filesystem::exists (filename_));
3638 }
3739
3840 void Stash (size_t index, string value) {
You can’t perform that action at this time.
0 commit comments