/* KMBuilderSourceArchive.h
 *
 * Copyright (C) 2023 OpenKylin, Inc
 */

#ifndef __BUILD_SOURCES_ARCHIVE_H__
#define __BUILD_SOURCES_ARCHIVE_H__

#include "KMBuilderSource.h"

class KMBuilderSourceArchive : public KMBuilderSource
{
    DECLARE_DYNCREATE(KMBuilderSourceArchive);

public:
    KMBuilderSourceArchive();
    ~KMBuilderSourceArchive();

    std::string getChecksum();
    std::string getUrl();
    bool ensureSource() { return true; }
    bool unzipSource() override;
    virtual std::pair<std::string, bool> processNode(std::string path);

    /**
     * @brief : 需要子类实现自身的反序列化
     * @param : [in]，sourceNode，清单中的源节点
     */ 
    virtual void deserializeEx(YAML::Node& sourceNode);

    // 源码下载，用于替换方法processNode的，后续有时间再彻底优化
    bool downloadSource(const std::string &destDir) override;

private:
    bool downloadByCurl(const std::string &zipFilePath, const std::string &url);

    class Private;
    std::shared_ptr<Private> m_ptr;
    std::string m_unzipDestination;
    std::string m_unzipSource;
};

#endif
