#pragma once #include #include #include namespace DB { class TemporaryFileOnDisk; class IDisk; using DiskPtr = std::shared_ptr; /// Represents a file prepared to be included in a backup, assuming that until this backup entry is destroyed the file won't be changed. class BackupEntryFromImmutableFile : public IBackupEntry { public: /// The constructor is allowed to not set `file_size_` or `checksum_`, in that case it will be calculated from the data. BackupEntryFromImmutableFile( const DiskPtr & disk_, const String & file_path_, const std::optional & file_size_ = {}, const std::optional & checksum_ = {}, const std::shared_ptr & temporary_file_ = {}); ~BackupEntryFromImmutableFile() override; UInt64 getSize() const override; std::optional getChecksum() const override { return checksum; } std::unique_ptr getReadBuffer() const override; String getFilePath() const { return file_path; } DiskPtr getDisk() const { return disk; } private: const DiskPtr disk; const String file_path; mutable std::optional file_size TSA_GUARDED_BY(get_file_size_mutex); mutable std::mutex get_file_size_mutex; const std::optional checksum; const std::shared_ptr temporary_file_on_disk; }; }