diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c59bb9667..66d381031 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,7 +63,7 @@ jobs: cd /Library zip -q -r ${OLDPWD}/libdigidocpp.${{ matrix.target }}.zip libdigidocpp.* - name: Archive artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: ${{ matrix.target }} path: | @@ -84,32 +84,24 @@ jobs: steps: - name: Checkout uses: actions/checkout@v5 - - name: Expose Android NDK env - shell: bash - run: | - echo "ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME" >> "$GITHUB_ENV" - echo "ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME" >> "$GITHUB_ENV" - name: Cache vcpkg uses: actions/cache@v4 with: path: ${{ github.workspace }}/vcpkg_cache key: vcpkg-${{ matrix.target }}-${{ hashFiles('vcpkg.json', 'vcpkg-ports/**') }} - - name: Prepare vcpkg - uses: lukka/run-vcpkg@v11 - with: - vcpkgJsonGlob: ./vcpkg.json - runVcpkgInstall: true + - name: Build env: VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite - VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }} - - name: Build run: | + export VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT + export ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME + export ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME cmake --preset ${{ matrix.target }} "-GUnix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake --build --preset ${{ matrix.target }} cmake --build --preset ${{ matrix.target }} --target install/strip zip -q -r libdigidocpp.${{ matrix.target }}.zip libdigidocpp.${{ matrix.target }} - name: Archive artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: ${{ matrix.target }} path: | @@ -120,7 +112,7 @@ jobs: container: fedora:${{ matrix.container }} strategy: matrix: - container: [41, 42, 43, rawhide] + container: [42, 43, rawhide] steps: - name: Install Deps run: | @@ -134,7 +126,7 @@ jobs: cmake --build build cmake --build build --target package - name: Archive artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: fedora_${{ matrix.container }} path: build/libdigidocpp*.rpm @@ -177,7 +169,7 @@ jobs: - name: Lintian run: lintian *.deb; - name: Archive artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: ${{ matrix.dist }}_${{ matrix.ver }}_${{ matrix.arch }} path: libdigidocpp*.* @@ -206,16 +198,6 @@ jobs: with: path: ${{ github.workspace }}/vcpkg_cache key: vcpkg-${{ matrix.toolset }}-${{ matrix.platform }}-${{ hashFiles('vcpkg.json', 'vcpkg-ports/**') }} - - name: Prepare vcpkg - uses: lukka/run-vcpkg@v11 - with: - vcpkgJsonGlob: ./vcpkg.json - runVcpkgInstall: true - runVcpkgFormatString: "[`install`, `--recurse`, `--clean-after-build`, `--x-install-root`, `$[env.VCPKG_INSTALLED_DIR]`, `--triplet`, `$[env.VCPKG_DEFAULT_TRIPLET]`, `--x-feature`, `tests`]" - env: - VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite - VCPKG_DEFAULT_TRIPLET: ${{ matrix.platform }}-windows - VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed_${{ matrix.platform }} - name: Install dependencies run: winget install --silent --accept-source-agreements --accept-package-agreements swig doxygen - uses: actions/setup-java@v4 @@ -228,14 +210,17 @@ jobs: python-version: 3.12 architecture: ${{ matrix.platform }} - name: Build + env: + VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite run: | $swig = (Get-Item "$env:LOCALAPPDATA\Microsoft\WinGet\Links\swig.exe").Target & "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat" ${{ matrix.setenv }} "&&" pwsh build.ps1 ` + -vcpkg "C:/vcpkg/vcpkg.exe" ` -swig $swig ` -doxygen "C:/Program files/doxygen/bin/doxygen.exe" ` -boost - name: Archive artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: msi_${{ matrix.toolset }}_${{ matrix.platform }} path: ./*.msi diff --git a/build.ps1 b/build.ps1 index 8db5b6512..0edf80204 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,7 +3,7 @@ param( [string]$libdigidocpp = $PSScriptRoot, [string]$platform = $env:PLATFORM, [string]$build_number = $(if ($null -eq $env:BUILD_NUMBER) {"0"} else {$env:BUILD_NUMBER}), - [string]$msiversion = "4.3.0.$build_number", + [string]$msiversion = "4.4.0.$build_number", [string]$msi_name = "libdigidocpp-$msiversion$env:VER_SUFFIX.$platform.msi", [string]$git = "git.exe", [string]$vcpkg = "vcpkg\vcpkg.exe", diff --git a/src/DataFile.cpp b/src/DataFile.cpp index cb7b83634..c7f425e46 100644 --- a/src/DataFile.cpp +++ b/src/DataFile.cpp @@ -83,16 +83,17 @@ using namespace std; DataFile::DataFile() = default; DataFile::~DataFile() = default; +struct DataFilePrivate::Private { + optional size; +}; DataFilePrivate::DataFilePrivate(unique_ptr &&is, string filename, string mediatype, string id) - : m_is(std::move(is)) + : d(make_unique()) + , m_is(std::move(is)) , m_id(std::move(id)) , m_filename(std::move(filename)) , m_mediatype(std::move(mediatype)) { - m_is->seekg(0, istream::end); - istream::pos_type pos = m_is->tellg(); - m_size = pos < 0 ? 0 : (unsigned long)pos; } void DataFilePrivate::digest(const Digest &digest) const @@ -109,6 +110,17 @@ vector DataFilePrivate::calcDigest(const string &method) const return d.result(); } +unsigned long DataFilePrivate::fileSize() const +{ + if(d->size.has_value()) + return d->size.value(); + m_is->clear(); + m_is->seekg(0, istream::end); + istream::pos_type pos = m_is->tellg(); + d->size.emplace(pos < 0 ? 0 : (unsigned long)pos); + return d->size.value(); +} + void DataFilePrivate::saveAs(const string& path) const { ofstream ofs(File::encodeName(path), ofstream::binary); diff --git a/src/DataFile_p.h b/src/DataFile_p.h index f21493ed0..3445a7564 100644 --- a/src/DataFile_p.h +++ b/src/DataFile_p.h @@ -23,6 +23,7 @@ #include #include +#include namespace digidoc { @@ -31,20 +32,21 @@ class Digest; class DataFilePrivate final: public DataFile { public: - DataFilePrivate(std::unique_ptr &&is, std::string filename, std::string mediatype, std::string id = {}); - - std::string id() const final { return m_id.empty() ? m_filename : m_id; } - std::string fileName() const final { return m_filename; } - unsigned long fileSize() const final { return m_size; } - std::string mediaType() const final { return m_mediatype; } - - void digest(const Digest &method) const; - std::vector calcDigest(const std::string &method) const final; - void saveAs(std::ostream &os) const final; - void saveAs(const std::string& path) const final; - - std::unique_ptr m_is; - std::string m_id, m_filename, m_mediatype; - unsigned long m_size; + DataFilePrivate(std::unique_ptr &&is, std::string filename, std::string mediatype, std::string id = {}); + + std::string id() const final { return m_id.empty() ? m_filename : m_id; } + std::string fileName() const final { return m_filename; } + unsigned long fileSize() const final; + std::string mediaType() const final { return m_mediatype; } + + void digest(const Digest &method) const; + std::vector calcDigest(const std::string &method) const final; + void saveAs(std::ostream &os) const final; + void saveAs(const std::string& path) const final; + + struct Private; + std::unique_ptr d; + std::unique_ptr m_is; + std::string m_id, m_filename, m_mediatype; }; }