diff options
Diffstat (limited to 'src/zen/cmds/admin_cmd.cpp')
| -rw-r--r-- | src/zen/cmds/admin_cmd.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/zen/cmds/admin_cmd.cpp b/src/zen/cmds/admin_cmd.cpp index 3422c6880..86a180d54 100644 --- a/src/zen/cmds/admin_cmd.cpp +++ b/src/zen/cmds/admin_cmd.cpp @@ -550,21 +550,9 @@ static void Copy(const std::filesystem::path& Source, const std::filesystem::path& Target) { CreateDirectories(Target.parent_path()); - BasicFile SourceFile; - SourceFile.Open(Source, BasicFile::Mode::kRead); - BasicFile TargetFile; - TargetFile.Open(Target, BasicFile::Mode::kTruncate); - uint64_t Size = SourceFile.FileSize(); - uint64_t Offset = 0; - std::vector<uint8_t> Buffer(Min(size_t(Size), size_t(65536u))); - while (Offset < Size) - { - uint64_t CopyCount = Min<uint64_t>(Size - Offset, size_t(Buffer.size())); - SourceFile.Read(Buffer.data(), CopyCount, Offset); - TargetFile.Write(Buffer.data(), CopyCount, Offset); - Offset += CopyCount; - } - TargetFile.Flush(); + + CopyFileOptions Options; + CopyFile(Source, Target, Options); } static bool @@ -574,8 +562,11 @@ TryCopy(const std::filesystem::path& Source, const std::filesystem::path& Target { return false; } - Copy(Source, Target); - return true; + + CreateDirectories(Target.parent_path()); + + CopyFileOptions Options; + return CopyFile(Source, Target, Options); } int @@ -630,6 +621,8 @@ CopyStateCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) std::filesystem::path BucketName = BucketPath.filename(); std::filesystem::path TargetBucketPath = TargetNamespacePath / BucketName; + // TODO: make these use file naming helpers from cache implementation? + std::filesystem::path ManifestPath = BucketPath / "zen_manifest"; std::filesystem::path TargetManifestPath = TargetBucketPath / "zen_manifest"; if (TryCopy(ManifestPath, TargetManifestPath)) @@ -646,6 +639,11 @@ CopyStateCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) std::filesystem::path IndexPath = BucketPath / IndexName; std::filesystem::path TargetIndexPath = TargetBucketPath / IndexName; TryCopy(IndexPath, TargetIndexPath); + + std::filesystem::path MetaName = fmt::format("{}.{}", BucketName.string(), "meta"); + std::filesystem::path MetaPath = BucketPath / MetaName; + std::filesystem::path TargetMetaPath = TargetBucketPath / MetaName; + TryCopy(MetaPath, TargetMetaPath); } } } |