Skip to content

Commit

Permalink
cst/cache: Extract tmp_filepath variable
Browse files Browse the repository at this point in the history
  • Loading branch information
nvartolomei committed Nov 4, 2024
1 parent 5a93114 commit 50fef29
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/v/cloud_storage/cache_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,7 @@ ss::future<> cache::put(
ss::this_shard_id(),
(++_cnt),
cache_tmp_file_extension));
auto tmp_filepath = dir_path / tmp_filename;

ss::file tmp_cache_file;
while (true) {
Expand All @@ -1268,14 +1269,14 @@ ss::future<> cache::put(
| ss::open_flags::exclusive;

tmp_cache_file = co_await ss::open_file_dma(
(dir_path / tmp_filename).native(), flags);
tmp_filepath.native(), flags);
break;
} catch (const std::filesystem::filesystem_error& e) {
if (e.code() == std::errc::no_such_file_or_directory) {
vlog(
cst_log.debug,
"Couldn't open {}, gonna retry",
(dir_path / tmp_filename).native());
tmp_filepath.native());
} else {
throw;
}
Expand Down Expand Up @@ -1318,12 +1319,10 @@ ss::future<> cache::put(
}

// commit write transaction
auto src = (dir_path / tmp_filename).native();
auto dest = (dir_path / filename).native();

auto put_size = co_await ss::file_size(src);
auto put_size = co_await ss::file_size(tmp_filepath.native());

co_await ss::rename_file(src, dest);
auto dest = (dir_path / filename).native();
co_await ss::rename_file(tmp_filepath.native(), dest);

// We will now update
reservation.wrote_data(put_size, 1);
Expand Down

0 comments on commit 50fef29

Please sign in to comment.