diff --git a/.github/workflows/build.yml b/.github/workflows/build-alpine.yml similarity index 90% rename from .github/workflows/build.yml rename to .github/workflows/build-alpine.yml index bc06035c..a6d4874b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build-alpine.yml @@ -1,4 +1,4 @@ -name: Build +name: Build (alpine) on: [push, pull_request] jobs: Build: @@ -22,11 +22,11 @@ jobs: id: buildx uses: docker/setup-buildx-action@v1 - - name: Build + - name: Build (alpine) uses: docker/build-push-action@v2 with: context: ./ - file: ./Dockerfile-build + file: ./Dockerfile-build-alpine builder: ${{ steps.buildx.outputs.name }} build-args: LMS_BUILD_TYPE=${{ matrix.BUILD_TYPE }} push: false diff --git a/.github/workflows/build-arch.yml b/.github/workflows/build-arch.yml new file mode 100644 index 00000000..ea06617c --- /dev/null +++ b/.github/workflows/build-arch.yml @@ -0,0 +1,34 @@ +name: Build (arch) +on: [push, pull_request] +jobs: + Build: + strategy: + matrix: + BUILD_TYPE: [Release, Debug] + runs-on: ubuntu-latest + steps: + - name: Check Out Repo + uses: actions/checkout@v2 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Build + uses: docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile-build-arch + builder: ${{ steps.buildx.outputs.name }} + build-args: LMS_BUILD_TYPE=${{ matrix.BUILD_TYPE }} + push: false + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/Dockerfile-build b/Dockerfile-build-alpine similarity index 100% rename from Dockerfile-build rename to Dockerfile-build-alpine diff --git a/Dockerfile-build-arch b/Dockerfile-build-arch new file mode 100644 index 00000000..eaecaaef --- /dev/null +++ b/Dockerfile-build-arch @@ -0,0 +1,26 @@ +FROM archlinux:latest + +ARG BUILD_PACKAGES="\ + clang \ + cmake \ + boost \ + ffmpeg \ + gtest \ + graphicsmagick \ + libconfig \ + make \ + pkgconfig \ + taglib \ + wt" + +RUN pacman -Syy +RUN pacman -S --noconfirm ${BUILD_PACKAGES} + +# LMS +COPY . /tmp/lms/ +ARG LMS_BUILD_TYPE="Release" +RUN \ + DIR=/tmp/lms/build && mkdir -p ${DIR} && cd ${DIR} && \ + cmake /tmp/lms/ -DCMAKE_BUILD_TYPE=${LMS_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=/usr && \ + VERBOSE=1 make -j$(nproc) && \ + make test diff --git a/src/libs/services/database/impl/ScanSettings.cpp b/src/libs/services/database/impl/ScanSettings.cpp index 70f08b72..13005720 100644 --- a/src/libs/services/database/impl/ScanSettings.cpp +++ b/src/libs/services/database/impl/ScanSettings.cpp @@ -67,7 +67,12 @@ std::vector ScanSettings::getAudioFileExtensions() const { const auto extensions {StringUtils::splitString(_audioFileExtensions, " ")}; - return std::vector(std::cbegin(extensions), std::cend(extensions)); + + std::vector res (std::cbegin(extensions), std::cend(extensions)); + std::sort(std::begin(res), std::end(res)); + res.erase(std::unique( std::begin(res), std::end(res)), std::end(res)); + + return res; } void diff --git a/src/libs/services/scanner/impl/ScannerService.cpp b/src/libs/services/scanner/impl/ScannerService.cpp index de5c94ae..fc712c13 100644 --- a/src/libs/services/scanner/impl/ScannerService.cpp +++ b/src/libs/services/scanner/impl/ScannerService.cpp @@ -69,11 +69,11 @@ getNextFirstOfMonth(Wt::WDate current) } bool -isFileSupported(const std::filesystem::path& file, const std::unordered_set& extensions) +isFileSupported(const std::filesystem::path& file, const std::vector& extensions) { const std::filesystem::path extension {StringUtils::stringToLower(file.extension().string())}; - return (extensions.find(extension) != extensions.end()); + return (std::find(std::cbegin(extensions), std::cend(extensions), extension) != std::cend(extensions)); } bool @@ -642,7 +642,7 @@ ScannerService::refreshScanSettings() { const auto fileExtensions {scanSettings->getAudioFileExtensions()}; _fileExtensions.clear(); - std::transform(std::cbegin(fileExtensions), std::end(fileExtensions), std::inserter(_fileExtensions, std::begin(_fileExtensions)), + std::transform(std::cbegin(fileExtensions), std::end(fileExtensions), std::back_inserter(_fileExtensions), [](const std::filesystem::path& extension) { return std::filesystem::path{ StringUtils::stringToLower(extension.string()) }; }); } _mediaDirectory = scanSettings->getMediaDirectory(); @@ -896,7 +896,7 @@ ScannerService::scanMediaDirectory(const std::filesystem::path& mediaDirectory, // Check if a file exists and is still in a media directory static bool -checkFile(const std::filesystem::path& p, const std::filesystem::path& mediaDirectory, const std::unordered_set& extensions) +checkFile(const std::filesystem::path& p, const std::filesystem::path& mediaDirectory, const std::vector& extensions) { try { diff --git a/src/libs/services/scanner/impl/ScannerService.hpp b/src/libs/services/scanner/impl/ScannerService.hpp index 0d8ecf91..9614bcb9 100644 --- a/src/libs/services/scanner/impl/ScannerService.hpp +++ b/src/libs/services/scanner/impl/ScannerService.hpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -114,7 +114,7 @@ namespace Scanner std::size_t _scanVersion {}; Wt::WTime _startTime; Database::ScanSettings::UpdatePeriod _updatePeriod {Database::ScanSettings::UpdatePeriod::Never}; - std::unordered_set _fileExtensions; + std::vector _fileExtensions; std::filesystem::path _mediaDirectory; Database::ScanSettings::RecommendationEngineType _recommendationServiceType; }; diff --git a/src/libs/utils/include/utils/Path.hpp b/src/libs/utils/include/utils/Path.hpp index b72e9cb4..e6361a5f 100644 --- a/src/libs/utils/include/utils/Path.hpp +++ b/src/libs/utils/include/utils/Path.hpp @@ -38,11 +38,3 @@ Wt::WDateTime getLastWriteTime(const std::filesystem::path& dir); // returns false if aborted by user bool exploreFilesRecursive(const std::filesystem::path& directory, std::function cb, const std::filesystem::path& excludeDirFileName = {}); -namespace std -{ - template <> - struct hash - { - inline std::size_t operator()(const std::filesystem::path &path) const { return hash_value(path); } - }; -}