Skip to content

Commit

Permalink
new (#144)
Browse files Browse the repository at this point in the history
* feat: support start anything server by systemd service

On V20 system, the service will keep disable status, and the anything
server will be started by dde-file-manager-daemon. On V25 system, the
service will keep enable status.

Log: support start anything server by systemd service
Bug: https://pms.uniontech.com/bug-view-281871.html

* chore: bump version 6.2.0

bump version

Log: bump version

* refactor: Refactor and address performance issues

This update involves a complete refactor of the project, resolving critical issues such as high CPU usage, real-time event processing, and data integrity. The program's scalability, reusability, and flexibility have been significantly improved.

* chore: Remove ignored files

Removed files that are listed in .gitignore to keep the repository clean.

* fix: dependency issue

As title

* fix: dependency issue

As title

* fix: tag confict

As title

* fix: add DBus connection and service registration checks

Improved error handling and logging for failed DBus operations.

* fix: resolve thread synchronization issues with the log module by switching to spdlog, add non-delayed disk scanning interface

Resolved multi-threading conflicts in log output by replacing the logging module with the spdlog library, which supports multi-threading. By default, disk scanning uses delayed indexing to reduce CPU usage, but indexing speed is slower. Added an interface to disable delayed indexing.

* fix: cppcheck error

As title

* feat: Adapt to v20 interface

Adapt the old interface so that DDE File Manager and DDE Grand Search remain unaffected by the new version of Anything on v20.

* feat: Improve tokenizer for more accurate path tokenization

Enhanced support for AnythingAnalyzer and AnythingTokenizer, resulting in more precise tokenization of paths.

* feat: Advanced search functionality

Added support for searching by type and time range.

* feat: Add syntax highlighting for keywords in search results

Implemented support for highlighting keywords in the search results, enhancing readability and user experience.

---------

Co-authored-by: rong wang <[email protected]>
  • Loading branch information
dxnu and wangrong1069 authored Jan 20, 2025
1 parent 55e3967 commit 0ad4cfb
Show file tree
Hide file tree
Showing 24 changed files with 1,296 additions and 200 deletions.
2 changes: 2 additions & 0 deletions config/dict.utf8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello
world
90 changes: 90 additions & 0 deletions config/filetypes.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Programming Language Files
.cpp=text/c++
.cxx=text/c++
.cc=text/c++
.c=text/c
.h=text/c
.hpp=text/c++
.cs=text/csharp
.java=text/java
.py=text/python
.js=application/javascript
.ts=application/typescript
.html=text/html
.css=text/css
.php=application/php
.rb=text/ruby
.go=text/go
.swift=text/swift
.kt=text/kotlin
.rs=text/rust
.lua=text/lua
.sh=application/shellscript
.bash=application/shellscript/shell/bash
.pl=text/perl
.sql=application/sql
.json=application/json
.xml=application/xml
.yaml=text/yaml
.toml=text/toml
.md=text/markdown
.r=text/r
.jl=text/julia/jl
.dart=text/dart
.scala=text/scala
.vb=text/vb
.asm=text/assembly/asm
.bat=application/batch
.make=text/makefile
.cmake=text/cmake
.gradle=text/gradle
.dockerfile=text/dockerfile

# Document Files
.txt=text/plain/txt
.pdf=application/pdf
.doc=application/doc
.docx=application/docx
.xls=application/xls
.xlsx=application/xlsx
.ppt=application/ppt
.pptx=application/pptx

# Image Files
.jpg=image/jpeg/jpg
.jpeg=image/jpeg
.png=image/png
.gif=image/gif
.bmp=image/bmp
.svg=image/svg+xml
.ico=image/vnd.microsoft.icon

# Audio Files
.mp3=audio/mpeg
.wav=audio/wav
.ogg=audio/ogg
.flac=audio/flac

# Video Files
.mp4=video/mp4
.avi=video/avi
.mov=video/mov
.mkv=video/mkv

# Compressed Files
.zip=application/zip
.tar=application/tar
.gz=application/gzip/gz
.rar=application/rar
.7z=application/7z

# Other Files
.iso=application/iso
.csv=text/csv
.epub=application/epub
.apk=application/apk
.exe=application/exe
.deb=package/deb
.a=library/a
.so=library/so
.dll=library/dll
2 changes: 1 addition & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
deepin-anything (7.0.5) unstable; urgency=medium
deepin-anything (7.0.6) unstable; urgency=medium

* Major update with a complete refactor and version upgrade.
* Fixed high CPU usage issues.
Expand Down
8 changes: 4 additions & 4 deletions src/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ pkg_check_modules(LUCENE_CONTRIB REQUIRED liblucene++-contrib)
# Generate QDbus file
# message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")
# message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
set(DBUS_ADAPTOR_SOURCES my.test.Anything.xml)
set(DBUS_ADAPTOR_SOURCES com.deepin.Anything.xml)
set(ANYTHING_DBUS_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/core/base_event_handler.h")
qt5_generate_dbus_interface(${ANYTHING_DBUS_HEADER}
my.test.Anything.xml
com.deepin.Anything.xml
OPTIONS -A
)
qt5_add_dbus_adaptor(DBUS_ADAPTOR_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/my.test.Anything.xml
${CMAKE_CURRENT_BINARY_DIR}/com.deepin.Anything.xml
${ANYTHING_DBUS_HEADER}
base_event_handler
)
Expand Down Expand Up @@ -81,4 +81,4 @@ install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
DESTINATION lib
)
)
37 changes: 37 additions & 0 deletions src/server/include/analyzers/AnythingAnalyzer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (C) 2024 UOS Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef ANYTHING_ANYTHING_ANALYZER_H_
#define ANYTHING_ANYTHING_ANALYZER_H_

#include <lucene++/LuceneHeaders.h>

#include "common/anything_fwd.hpp"

ANYTHING_NAMESPACE_BEGIN

using namespace Lucene;

class AnythingAnalyzer : public Analyzer {
public:
TokenStreamPtr tokenStream(const String&, const ReaderPtr& reader) override;

TokenStreamPtr reusableTokenStream(const String&, const ReaderPtr& reader) override;
};

class AnythingAnalyzerSavedStreams : public LuceneObject {
public:
virtual ~AnythingAnalyzerSavedStreams();

LUCENE_CLASS(AnythingAnalyzerSavedStreams);

public:
TokenizerPtr source;
TokenStreamPtr result;
};

ANYTHING_NAMESPACE_END

#endif // ANYTHING_ANYTHING_ANALYZER_H_
32 changes: 32 additions & 0 deletions src/server/include/analyzers/AnythingFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (C) 2024 UOS Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef ANYTHING_ANYTHING_FILTER_H_
#define ANYTHING_ANYTHING_FILTER_H_

#include <lucene++/LuceneHeaders.h>

#include "common/anything_fwd.hpp"

ANYTHING_NAMESPACE_BEGIN

using namespace Lucene;

class AnythingFilter : public TokenFilter {
public:
AnythingFilter(const TokenStreamPtr& input);

bool incrementToken() override;

private:
HashSet<String> stopTable_;
TermAttributePtr termAtt_;

static const wchar_t* STOP_WORDS[];
};

ANYTHING_NAMESPACE_END

#endif // ANYTHING_ANYTHING_FILTER_H_
66 changes: 66 additions & 0 deletions src/server/include/analyzers/AnythingTokenizer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright (C) 2024 UOS Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef ANYTHING_ANYTHING_TOKENIZER_H_
#define ANYTHING_ANYTHING_TOKENIZER_H_

#include <unordered_set>

#include <lucene++/LuceneHeaders.h>

#include "common/anything_fwd.hpp"

ANYTHING_NAMESPACE_BEGIN

using namespace Lucene;

class AnythingTokenizer : public Tokenizer {
public:
AnythingTokenizer(const ReaderPtr& input);

void initialize() override;
bool incrementToken() override;
void end() override;
void reset() override;
void reset(const ReaderPtr& input) override;

private:
void push(wchar_t c);
bool flush();

public:
static bool isSymbol(wchar_t c);
static bool isDot(wchar_t c);
static bool isLastDot(wchar_t c, int32_t offset, std::wstring buf);
bool is_word(wchar_t* buf, int32_t len);

private:
/// word offset, used to imply which character(in) is parsed
int32_t offset_;

/// the index used only for ioBuffer
int32_t bufferIndex_;

/// data length
int32_t dataLen_;

/// character buffer, store the characters which are used to compose the returned Token
CharArray buffer_;

/// I/O buffer, used to store the content of the input (one of the members of Tokenizer)
CharArray ioBuffer_;

TermAttributePtr termAtt_;
OffsetAttributePtr offsetAtt_;

int32_t length_;
int32_t start_;

std::unordered_set<std::wstring> words_;
};

ANYTHING_NAMESPACE_END

#endif // ANYTHING_ANYTHING_TOKENIZER_H_
63 changes: 63 additions & 0 deletions src/server/include/common/file_record.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (C) 2024 UOS Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef ANYTHING_FILE_RECORD_H_
#define ANYTHING_FILE_RECORD_H_

#include <filesystem>
#include <string>
#include <unordered_map>

#include "common/anything_fwd.hpp"

ANYTHING_NAMESPACE_BEGIN

struct file_record {
std::string file_name;
std::string full_path;
std::string file_type;
int64_t creation_time; // milliseconds time since epoch
};

class file_helper {
public:
file_helper();

file_record make_file_record(const std::filesystem::path& p);

int64_t get_file_creation_time(const std::filesystem::path& file_path);
int64_t to_milliseconds_since_epoch(std::string date_time);

private:
bool is_valid_date_format(std::string& date_str);

private:
std::unordered_map<std::string, std::string> extension_mapper_;
};

// namespace file_helper {

// namespace fs = std::filesystem;

// inline file_record make_file_record(const fs::path& p) {
// auto handle = ::magic_open(MAGIC_MIME_TYPE);
// ::magic_load(handle, NULL);
// auto file_type = ::magic_file(handle, p.native().c_str());
// std::string type(file_type ? file_type : "unknown");

// ::magic_close(handle);

// return file_record {
// .file_name = p.filename().string(),
// .full_path = p.string(),
// .file_type = std::move(type)
// };
// }

// } // namespace file_helper

ANYTHING_NAMESPACE_END

#endif // ANYTHING_FILE_RECORD_H_
37 changes: 0 additions & 37 deletions src/server/include/common/file_record.hpp

This file was deleted.

Loading

0 comments on commit 0ad4cfb

Please sign in to comment.