sstables: Fix use-after-move in an error path of FS-based sstable writer

```
sstables/storage.cc:152:21: warning: 'file_path' used after it was moved [bugprone-use-after-move]
        remove_file(file_path).get();
                    ^
sstables/storage.cc:145:64: note: move occurred here
    auto w = file_writer(output_stream<char>(std::move(sink)), std::move(file_path));

```

It's a regression when TOC is found for a new sstable, and we try to delete temporary TOC.

courtesy of clang-tidy.

Fixes #18323.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>

Closes scylladb/scylladb#18367
This commit is contained in:
Raphael S. Carvalho
2024-04-23 05:23:20 -03:00
committed by Botond Dénes
parent f5f57dc817
commit fa2dc5aefa

View File

@@ -151,7 +151,7 @@ void filesystem_storage::open(sstable& sst) {
// TOC will exist at this point if write_components() was called with
// the generation of a sstable that exists.
w.close();
remove_file(file_path).get();
remove_file(sst.filename(component_type::TemporaryTOC)).get();
throw std::runtime_error(format("SSTable write failed due to existence of TOC file for generation {} of {}.{}", sst._generation, sst._schema->ks_name(), sst._schema->cf_name()));
}