Skip to content

Commit

Permalink
Merge branch 'develop' for release v3.29.1
Browse files Browse the repository at this point in the history
  • Loading branch information
epoupon committed May 28, 2022
2 parents a2ce905 + 8d0bbd0 commit b9a57e4
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build (alpine)
on: [push, pull_request]
jobs:
Build:
Expand All @@ -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
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/build-arch.yml
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
26 changes: 26 additions & 0 deletions Dockerfile-build-arch
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions Dockerfile-release
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.16 AS build
FROM alpine:3.14 AS build

WORKDIR /tmp/workdir

Expand Down Expand Up @@ -132,7 +132,7 @@ RUN \
rm -rf /tmp/fakeroot/share/Wt/resources/themes

## Release Stage
FROM alpine:3.16 AS release
FROM alpine:3.14 AS release
LABEL maintainer="Emeric Poupon <[email protected]>"

ARG RUNTIME_PACKAGES=" \
Expand Down
7 changes: 6 additions & 1 deletion src/libs/services/database/impl/ScanSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ std::vector<std::filesystem::path>
ScanSettings::getAudioFileExtensions() const
{
const auto extensions {StringUtils::splitString(_audioFileExtensions, " ")};
return std::vector<std::filesystem::path>(std::cbegin(extensions), std::cend(extensions));

std::vector<std::filesystem::path> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ FeaturesEngine::loadFromTraining(const TrainSettings& trainSettings, const Progr
}

void
FeaturesEngine::loadFromCache(FeaturesEngineCache cache)
FeaturesEngine::loadFromCache(FeaturesEngineCache&& cache)
{
LMS_LOG(RECOMMENDATION, INFO) << "Constructing features classifier from cache...";

Expand Down Expand Up @@ -341,9 +341,9 @@ FeaturesEngine::load(bool forceReload, const ProgressCallback& progressCallback)
{
FeaturesEngineCache::invalidate();
}
else if (const std::optional<FeaturesEngineCache> cache {FeaturesEngineCache::read()})
else if (std::optional<FeaturesEngineCache> cache {FeaturesEngineCache::read()})
{
loadFromCache(*cache);
loadFromCache(std::move(*cache));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class FeaturesEngine : public IEngine
ReleaseContainer getSimilarReleases(Database::ReleaseId releaseId, std::size_t maxCount) const override;
ArtistContainer getSimilarArtists(Database::ArtistId artistId, EnumSet<Database::TrackArtistLinkType> linkTypes, std::size_t maxCount) const override;

void loadFromCache(FeaturesEngineCache cache);
void loadFromCache(FeaturesEngineCache&& cache);

// Use training (may be very slow)
struct TrainSettings
Expand Down
8 changes: 4 additions & 4 deletions src/libs/services/scanner/impl/ScannerService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ getNextFirstOfMonth(Wt::WDate current)
}

bool
isFileSupported(const std::filesystem::path& file, const std::unordered_set<std::filesystem::path>& extensions)
isFileSupported(const std::filesystem::path& file, const std::vector<std::filesystem::path>& 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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<std::filesystem::path>& extensions)
checkFile(const std::filesystem::path& p, const std::filesystem::path& mediaDirectory, const std::vector<std::filesystem::path>& extensions)
{
try
{
Expand Down
4 changes: 2 additions & 2 deletions src/libs/services/scanner/impl/ScannerService.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <chrono>
#include <shared_mutex>
#include <optional>
#include <unordered_set>
#include <vector>

#include <Wt/WDateTime.h>
#include <Wt/WIOService.h>
Expand Down Expand Up @@ -114,7 +114,7 @@ namespace Scanner
std::size_t _scanVersion {};
Wt::WTime _startTime;
Database::ScanSettings::UpdatePeriod _updatePeriod {Database::ScanSettings::UpdatePeriod::Never};
std::unordered_set<std::filesystem::path> _fileExtensions;
std::vector<std::filesystem::path> _fileExtensions;
std::filesystem::path _mediaDirectory;
Database::ScanSettings::RecommendationEngineType _recommendationServiceType;
};
Expand Down
8 changes: 0 additions & 8 deletions src/libs/utils/include/utils/Path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool(std::error_code, const std::filesystem::path&)> cb, const std::filesystem::path& excludeDirFileName = {});

namespace std
{
template <>
struct hash<std::filesystem::path>
{
inline std::size_t operator()(const std::filesystem::path &path) const { return hash_value(path); }
};
}

0 comments on commit b9a57e4

Please sign in to comment.