diff options
| author | Matt Peters <[email protected]> | 2022-01-10 10:57:59 -0700 |
|---|---|---|
| committer | Matt Peters <[email protected]> | 2022-01-10 10:57:59 -0700 |
| commit | 4a12683b27adb31bde9eb8f7df3b9e9cc8ec680a (patch) | |
| tree | c8b2939d400dd4bccae73d2782b15c65d30db19d /zenstore/filecas.cpp | |
| parent | Add WaitForQuiescence RPC (diff) | |
| parent | Two missing override keywords (diff) | |
| download | zen-wait_for_quiescence.tar.xz zen-wait_for_quiescence.zip | |
Merge branch 'main' into wait_for_quiescencewait_for_quiescence
Diffstat (limited to 'zenstore/filecas.cpp')
| -rw-r--r-- | zenstore/filecas.cpp | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp index 76b921994..533c99569 100644 --- a/zenstore/filecas.cpp +++ b/zenstore/filecas.cpp @@ -35,8 +35,6 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen { -using namespace fmt::literals; - FileCasStrategy::ShardingHelper::ShardingHelper(const std::filesystem::path& RootPath, const IoHash& ChunkHash) { ShardedPath.Append(RootPath.c_str()); @@ -241,7 +239,7 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash) if (FAILED(hRes)) { - ThrowSystemException(hRes, "Failed to open shard directory '{}'"_format(FilePath)); + ThrowSystemException(hRes, fmt::format("Failed to open shard directory '{}'", FilePath)); } // Retry rename/move @@ -271,7 +269,7 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash) ChunkHash); DeletePayloadFileOnClose(); -#elif ZEN_PLATFORM_LINUX +#elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC std::filesystem::path SourcePath = PathFromHandle(FileRef.FileHandle); std::filesystem::path DestPath = Name.ShardedPath.c_str(); int Ret = link(SourcePath.c_str(), DestPath.c_str()); @@ -311,8 +309,6 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash) { return CasStore::InsertResult{.New = true}; } -#else -# error check link/unlink for this platform #endif // ZEN_PLATFORM_* } @@ -345,13 +341,11 @@ FileCasStrategy::InsertChunk(const void* const ChunkData, const size_t ChunkSize } PayloadFile.Close(); -#elif ZEN_PLATFORM_LINUX +#elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC if (access(Name.ShardedPath.c_str(), F_OK) == 0) { return CasStore::InsertResult{.New = false}; } -#else -# error Check access() for this platform #endif RwLock::ExclusiveLockScope _(LockForHash(ChunkHash)); @@ -390,7 +384,7 @@ FileCasStrategy::InsertChunk(const void* const ChunkData, const size_t ChunkSize if (FAILED(hRes)) { - ThrowSystemException(hRes, "Failed to open shard file '{}'"_format(Name.ShardedPath.ToUtf8())); + ThrowSystemException(hRes, fmt::format("Failed to open shard file '{}'", Name.ShardedPath.ToUtf8())); } #else // Attempt to exclusively create the file. @@ -413,10 +407,10 @@ FileCasStrategy::InsertChunk(const void* const ChunkData, const size_t ChunkSize break; } } - ThrowLastError("Failed creating shard directory '{}'"_format(Name.ShardedPath)); + ThrowLastError(fmt::format("Failed creating shard directory '{}'", Name.ShardedPath)); default: - ThrowLastError("Unexpected error occurred opening shard file '{}'"_format(Name.ShardedPath)); + ThrowLastError(fmt::format("Unexpected error occurred opening shard file '{}'", Name.ShardedPath)); } } @@ -573,7 +567,7 @@ FileCasStrategy::IterateChunks(std::function<void(const IoHash& Hash, BasicFile& } } - virtual bool VisitDirectory([[maybe_unused]] const std::filesystem::path& Parent, [[maybe_unused]] const path_view& DirectoryName) + virtual bool VisitDirectory([[maybe_unused]] const std::filesystem::path& Parent, [[maybe_unused]] const path_view& DirectoryName) override { return true; } @@ -727,8 +721,6 @@ FileCasStrategy::CollectGarbage(GcContext& GcCtx) TEST_CASE("cas.file.move") { - using namespace fmt::literals; - // specifying an absolute path here can be helpful when using procmon to dig into things ScopedTemporaryDirectory TempDir; // {"d:\\filecas_testdir"}; @@ -773,7 +765,7 @@ TEST_CASE("cas.file.move") *reinterpret_cast<int*>(Payload.MutableData()) = i; PayloadHashes.push_back(IoHash::HashBuffer(Payload)); - std::filesystem::path PayloadPath{TempDir.Path() / "payload_{}_{}"_format(w, i)}; + std::filesystem::path PayloadPath{TempDir.Path() / fmt::format("payload_{}_{}", w, i)}; WriteFile(PayloadPath, Payload); } } @@ -785,7 +777,7 @@ TEST_CASE("cas.file.move") for (int i = 0; i < kItemCount; ++i) { - std::filesystem::path PayloadPath{TempDir.Path() / "payload_{}_{}"_format(w, i)}; + std::filesystem::path PayloadPath{TempDir.Path() / fmt::format("payload_{}_{}", w, i)}; IoBuffer Payload = IoBufferBuilder::MakeFromTemporaryFile(PayloadPath); Buffers.push_back(Payload); Sync.arrive_and_wait(); |