Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
lalinsky committed Feb 25, 2024
2 parents e035a86 + 269be11 commit a3299b4
Show file tree
Hide file tree
Showing 24 changed files with 4,283 additions and 3,184 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ env:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- run: |
sudo apt-get update
sudo apt-get install -y qtbase5-dev libgtest-dev libgrpc++-dev protobuf-compiler-grpc protobuf-compiler libsqlite3-dev
sudo apt-get install -y qt6-base-dev libgtest-dev libgrpc++-dev protobuf-compiler-grpc protobuf-compiler libsqlite3-dev
- run: cmake -DCMAKE_BUILD_TYPE=Release .
- run: make
- run: make check
Expand Down
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(CMAKE_AUTORCC ON)
find_package(Threads REQUIRED)
find_package(GTest)
find_package(SQLite3 REQUIRED)
find_package(Qt5 COMPONENTS Core Network Concurrent REQUIRED)
find_package(Qt6 COMPONENTS Core Network Concurrent REQUIRED)

find_package(PkgConfig REQUIRED)
pkg_search_module(PROTOBUF REQUIRED IMPORTED_TARGET protobuf)
Expand Down Expand Up @@ -89,10 +89,11 @@ set(fpindexlib_SOURCES
src/store/sqlite/statement.h
src/util/crc.c
src/util/options.cpp
src/util/tracing.cpp
)

add_library(fpindexlib ${fpindexlib_SOURCES})
target_link_libraries(fpindexlib Qt5::Core Qt5::Network Qt5::Concurrent SQLite::SQLite3)
target_link_libraries(fpindexlib Qt6::Core Qt6::Network Qt6::Concurrent SQLite::SQLite3)

set(qhttp_SOURCES
./src/3rdparty/qhttp/src/qhttpserverconnection.cpp
Expand All @@ -107,7 +108,7 @@ set(qhttp_SOURCES
)
add_library(qhttp ${qhttp_SOURCES})
target_include_directories(qhttp PRIVATE ./src/3rdparty/)
target_link_libraries(qhttp Qt5::Core Qt5::Network Qt5::Concurrent)
target_link_libraries(qhttp Qt6::Core Qt6::Network Qt6::Concurrent)

set(fpserver_SOURCES
src/server/listener.cpp
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN useradd -m -s /bin/bash -u 1000 acoustid

<<<<<<< HEAD
=======
RUN apt-get update && \
apt-get install -y libqt6network6 libqt6core6 libstdc++6 libgcc1 libgcc-s1

>>>>>>> origin/stable
ADD acoustid-index.deb /tmp/
RUN apt update && apt install -y /tmp/acoustid-index.deb && rm /tmp/acoustid-index.deb

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ Starting server locally:

- C/C++ compiler supporting at least C++17
- CMake
- Qt5, at least the QtCore, QtNetwork and QtConcurrent components
- Qt6, at least the QtCore, QtNetwork and QtConcurrent components
- GoogleTest (optional)

### For Debian
```
# apt install git gcc g++ cmake pkg-config qtbase5-dev libsqlite3-dev libprotobuf-dev libgrpc++-dev libgtest-dev protobuf-compiler protobuf-compiler-grpc
# ./update_proto.sh
# cmake .
# cmake --build .
# ./update_proto.sh
# make
```

### Building the code
Expand Down
6 changes: 5 additions & 1 deletion src/index/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using namespace Acoustid;

Index::Index(DirectorySharedPtr dir, bool create)
: m_mutex(QMutex::Recursive), m_dir(dir), m_open(false),
: m_mutex(), m_dir(dir), m_open(false),
m_hasWriter(false),
m_deleter(new IndexFileDeleter(dir))
{
Expand All @@ -36,9 +36,11 @@ bool Index::exists(const QSharedPointer<Directory> &dir) {

void Index::open(bool create)
{
QMutexLocker locker(&m_mutex);
if (!m_info.load(m_dir.data(), true)) {
if (create) {
IndexWriter(m_dir, m_info).commit();
locker.unlock();
return open(false);
}
throw IOException("there is no index in the directory");
Expand All @@ -53,6 +55,7 @@ QSharedPointer<IndexReader> Index::openReader()
if (!m_open) {
throw IndexIsNotOpen("index is not open");
}
locker.unlock();
return QSharedPointer<IndexReader>::create(sharedFromThis());
}

Expand All @@ -63,6 +66,7 @@ QSharedPointer<IndexWriter> Index::openWriter(bool wait, int64_t timeoutInMSecs)
throw IndexIsNotOpen("index is not open");
}
acquireWriterLockInt(wait, timeoutInMSecs);
locker.unlock();
return QSharedPointer<IndexWriter>::create(sharedFromThis(), true);
}

Expand Down
2 changes: 1 addition & 1 deletion src/index/index_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void IndexWriter::merge(const QList<int>& merge)
throw CorruptIndexException("checksum mismatch after merge");
}

QSet<int> merged = merge.toSet();
QSet<int> merged = QSet<int>(merge.begin(), merge.end());
info.clearSegments();
for (size_t i = 0; i < segments.size(); i++) {
const SegmentInfo& s = segments.at(i);
Expand Down
2 changes: 2 additions & 0 deletions src/index/search_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#ifndef ACOUSTID_INDEX_SEARCH_RESULT_H_
#define ACOUSTID_INDEX_SEARCH_RESULT_H_

#include <iostream>

namespace Acoustid {

class SearchResult {
Expand Down
6 changes: 5 additions & 1 deletion src/index/search_result_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@

using namespace Acoustid;

std::ostream& operator<<(std::ostream& stream, const SearchResult& result) {
namespace Acoustid {

std::ostream& operator<<(std::ostream& stream, const SearchResult & result) {
return stream << "SearchResult(docId=" << result.docId() << ", score=" << result.score() << ", version=" << result.version() <<")";
}

}

TEST(SearchResultTest, SortSearchResults) {
std::vector<SearchResult> results = {
{ 100, 1, 0 },
Expand Down
2 changes: 1 addition & 1 deletion src/index/segment_merge_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ QList<int> SegmentMergePolicy::findMerges(const SegmentInfoList& infos)
for (size_t i = 0; i < infos.size(); i++) {
segments.append(i);
}
qStableSort(segments.begin(), segments.end(), SegmentSizeLessThan(&infos));
std::stable_sort(segments.begin(), segments.end(), SegmentSizeLessThan(&infos));
//qDebug() << "Order after sorting is " << segments;

size_t minSegmentSize = infos.at(segments.last()).blockCount();
Expand Down
2 changes: 2 additions & 0 deletions src/server/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "errors.h"
#include "protocol.h"
#include "metrics.h"
#include "util/tracing.h"

using namespace Acoustid;
using namespace Acoustid::Server;
Expand Down Expand Up @@ -133,6 +134,7 @@ void Connection::readIncomingData()
}

auto futureResult = QtConcurrent::run([=]() {
setTraceId(m_session->getTraceId());
QString response;
try {
response = renderResponse(handler());
Expand Down
Loading

0 comments on commit a3299b4

Please sign in to comment.