Vergelijk commits
39 Commits
Auteur | SHA1 | Datum | |
---|---|---|---|
399c27a452 | |||
7a2e4aaec1 | |||
11decb757f | |||
b71c234fb4 | |||
bc908a1038 | |||
8ba4ee5847 | |||
451c79088a | |||
1a39118470 | |||
0d2e518000 | |||
b108cb7151 | |||
c82cf03814 | |||
8a82da95bd | |||
a408173064 | |||
dd479fa668 | |||
e76988ee77 | |||
f29f997289 | |||
afa9d33f3d | |||
fc92b963d4 | |||
9acbd5dccf | |||
87ebc137d5 | |||
67189f34c6 | |||
fac6ed1853 | |||
ae2097fe6a | |||
9e3d3b1dd4 | |||
4f3abb3f67 | |||
3ca6e4df3c | |||
0d81452a67 | |||
3e14498437 | |||
3102a952df | |||
3903f18854 | |||
60a91967bb | |||
c6550e81bb | |||
744fa2ec7a | |||
f8542dc96a | |||
fdae7fd065 | |||
f8d6a1a586 | |||
61fa7ca16d | |||
61a446ec2d | |||
0e5abf96c8 |
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
.user
|
||||
.o
|
||||
*.user
|
||||
*.o
|
||||
*.a
|
||||
moc_*.cpp
|
||||
moc_*.h
|
||||
Makefile
|
||||
cli/looqs
|
||||
gui/looqs-gui
|
||||
qrc_*
|
39
CHANGELOG.md
39
CHANGELOG.md
@ -1,22 +1,47 @@
|
||||
# looqs: Release notes
|
||||
|
||||
## 2022-06-XX - v0.1
|
||||
## 2022-06-14 - v0.3
|
||||
CHANGES:
|
||||
- GUI: Add settings tab to configure various settings
|
||||
- GUI: Don't render previews for results that do not originate from a content search. This was confusing.
|
||||
- GUI: Remove 'open config file' menu action
|
||||
- GUI: Highlight "words" that are actually numbers in preview texts
|
||||
- search: Search for "words" that are a number, e. g. 23. Previously, those were ignored due to a regression.
|
||||
- CLI: Minor cleanups.
|
||||
- sandbox: Improve preview generation sandbox further by restricting it more
|
||||
- sandbox: Fix case where activiation would fail during indexing in some cases on kernels without landlock.
|
||||
- Remove 'firstrun' setting
|
||||
|
||||
|
||||
## 2022-06-07 - v0.2
|
||||
CHANGES:
|
||||
- Sandboxing: Add environment variable `LOOQS_DISABLE_SANDBOXING` to disable sandboxing. This is intended for troubleshooting
|
||||
- Sandboxing: Fix issue where activation failed on kernels without landlock
|
||||
|
||||
## 2022-06-06 - v0.1
|
||||
The first release comes with basic functionality. It's a start that can be considered useful to some degree.
|
||||
|
||||
looqs is still at an early stage and may exhibit some weirdness and contain bugs.
|
||||
|
||||
Tested architectures: amd64.
|
||||
|
||||
CHANGES:
|
||||
- CLI command "looqs" to add/update/delete and search
|
||||
- GUI: "looqs-gui" to search, render previews, and add files to index
|
||||
CHANGES:
|
||||
- CLI command "looqs" to add/update/delete and search
|
||||
- GUI: "looqs-gui" to search, render previews, and add files to index
|
||||
- General: Add multi-threaded indexing of all files (paths, mtime)
|
||||
- General: Generate sqlite based full-text search index for: .pdf,.odt,.ods, text files
|
||||
- General: Sandboxed content processing
|
||||
- GUI: Sandboxed IPC sub-process to render previews.
|
||||
- GUI: Add previews for pdf: Render the page the search keywords were found. Highlight the keywords when rendering the page.
|
||||
- GUI: Add previews for plaintext files: Extract snippets. Highlight the keywords when rendering the page.
|
||||
- GUI: Add previews for pdf: Render the page the search keywords were found. Highlight the keywords when rendering the page.
|
||||
- GUI: Add previews for plaintext files: Extract snippets. Highlight the keywords when rendering the page.
|
||||
- General: Add basic filters for query.
|
||||
- Add packages: Ubuntu 22.04
|
||||
- GUI: Add icon. Special thanks to the following sources:
|
||||
https://www.svgrepo.com/svg/151751/magnifier-with-small-handle
|
||||
https://www.svgrepo.com/svg/52764/open-book
|
||||
|
||||
Thanks!
|
||||
- General: Documentation.
|
||||
|
||||
- Add packages: Ubuntu 21.10, 22.04
|
||||
|
||||
Thanks to all those who provided feedback (and endured bugs) at various stages. You know who you are, thx!
|
||||
|
26
CONTRIBUTING.md
Normal file
26
CONTRIBUTING.md
Normal file
@ -0,0 +1,26 @@
|
||||
# looqs - Contributing
|
||||
Contributions are welcome, please use the following guidelines.
|
||||
|
||||
## Repository
|
||||
The github repository https://github.com/quitesimpleorg/looqs is the primary one. Pull-Requests and Issues go there, but you can also submit your feedback there.
|
||||
|
||||
Those who prefer a more classical approach can mail their patches etc. to looqs at quitesimple org. Ideally git-format patch and git send-email.
|
||||
|
||||
The repository at https://gitea.quitesimple.org/crtxcr/looqs was supposed to be the main one, but these
|
||||
plans are on hold for the time being. Just ignore it.
|
||||
|
||||
## Pull-Requests & Rebasing
|
||||
Your merge requests should be submitted against the dev branch. master branch won't be rebased. I'll try to avoid in the dev branch. I definitly rebase WIP/feature branches.
|
||||
|
||||
|
||||
## Commit messages
|
||||
Commit messages begin with the component your change affects, e. g. "gui:", "cli:", "shared:", followed by the class.
|
||||
Then choose an appropriate verb in present tense. Wrong: Fixed, Fixes. Correct: Fix. Make sure lines are not too long,
|
||||
I personally go by gut feeling in this matter.
|
||||
|
||||
If your change has an issue, link it at the end: Closes: https://github.com/quitesimpleorg/looqs/issues/1
|
||||
|
||||
Example: "shared: Indexer: Use WildcardMatcher to ignore paths"
|
||||
|
||||
## License
|
||||
You license your changes under the GPLv3 by contributing.
|
33
HACKING.md
Normal file
33
HACKING.md
Normal file
@ -0,0 +1,33 @@
|
||||
# looqs - Hacking
|
||||
|
||||
## Introduction
|
||||
Without elaborating here, I hacked looqs because I was not satisfied with the state of desktop search on Linux.
|
||||
|
||||
Originally a set of CLI python scripts, it is now written in C++ and offers a GUI made using Qt. While a "web app" would have been an option, I prefer a desktop application for something like looqs. I chose Qt because I am more familiar with it than with any other GUI framework. To my knowledge, potential alternatives like GTK do not include as many "batteries" as Qt anyway, so the job presumably would have been harder there,
|
||||
at least for me.
|
||||
|
||||
If you are interested in how to contribute, please see the file [CONTRIBUTING.md](CONTRIBUTING.md) which contains the instructions on how to submit patches etc.
|
||||
|
||||
## Security
|
||||
The architecture ensures that the parsing of documents and the preview generation is sandboxed by [exile.h](https://github.com/quitesimpleorg/exile.h). looqs uses a multi-process architecture to achieve this.
|
||||
|
||||
Qt code is considered trusted in this model. While one may critize this, it was the only practical solution. looqs uses Qt's serialization mechanism and other classes to communicate between the non-sandboxed GUI process and the sandboxed processes.
|
||||
|
||||
Set the enviornment variable `LOOQS_DISABLE_SANDBOX=1` to disable sandboxing. It's intended for troublehshooting.
|
||||
|
||||
## Database
|
||||
The heart is sqlite, with the FTS5 extensions behind the full-text search. While FTS may not be sqlite's strong suit, I definitly did not want to run one of those oftenly recommended heavy (Java based) solutions. I explored other options like Postgresql, I've discard them due to some limitations back then.
|
||||
|
||||
Down the road, alternatives will be explored of course if sqlite should not suffice anymore.
|
||||
|
||||
## File format support
|
||||
The pdf library is libpoppler. Files such as .odt or .docx documents are opened with libquazip. The XML files in there are not parsed,
|
||||
looqs simply strips the tags and that seems to work fine so far. Naturally, this is not the "proper way", so there is room for improvement maybe here. However, those file formats are not a huge priortiy for me personally. libuchardet does encoding detection and conversion.
|
||||
|
||||
Naturally, looqs won't be able to index and render previews for everything. Such approach would create a huge bloated binary. In the future, there will be some plugin system of some sorts, either we will load .so objects or use subprocesses.
|
||||
|
||||
## Name
|
||||
looqs looks for files. You as the user can also look inside them. The 'k' in "looks" was replaced by a 'q'. Originally, I wanted my projects to have "qs" (for quitesimple) in their name. While abandoned now, this got us to looqs.
|
||||
|
||||
|
||||
|
70
README.md
70
README.md
@ -2,20 +2,35 @@
|
||||
looqs is a tool that creates a full-text search index for your files. It allows you to look at previews where your
|
||||
search terms have been found, as shown in the screenshots below.
|
||||
|
||||
|
||||
## Screenshots
|
||||
The screenshots in this section may occasionally be slightly outdated, but they are usually recent enough to get an overall impression of the current state.
|
||||
|
||||
### List
|
||||

|
||||
The screenshots in this section may occasionally be slightly outdated, but they are usually recent enough to get an overall impression of the current state of the GUI.
|
||||
|
||||
### Preview
|
||||
looqs allow you to look inside files. It marks what you have searched for.
|
||||
|
||||

|
||||

|
||||
|
||||
### Results list
|
||||
#### Classic results list
|
||||
Just enter what you want to find, it will search paths and file content.
|
||||

|
||||
|
||||
#### Searching with filters
|
||||
You can be more specific to get what you want with filters
|
||||
|
||||
**Filters (long form)**
|
||||

|
||||
|
||||
**Filters (short form)**
|
||||
|
||||
There is no need to write the long form of filters. There are also booleans available
|
||||
|
||||

|
||||
|
||||
|
||||
## Current status
|
||||
Last version: 2022-0X-XX, v0.1
|
||||
Last version: 2022-06-14, v0.3
|
||||
|
||||
Please see [Changelog](CHANGELOG.md) for a human readable list of changes.
|
||||
|
||||
@ -23,10 +38,20 @@ Please see [Changelog](CHANGELOG.md) for a human readable list of changes.
|
||||
## Goals and principles
|
||||
* **Find & Preview**. Instead of merely telling you where your search phrase has been found, it should also render the corresponding portion/pages of the documents and highlight the searched words.
|
||||
* **No daemons**. As some other desktop search projects are prone to have annoying daemons running that eat system resources away, this solution should make do without daemons where possible.
|
||||
* **Easy setup**. Similiarly, there should be no need for heavy-weight databases. Instead, this solution tries to squeeze out the most from simple approaches. In particular, it relies on sqlite.
|
||||
* **Easy setup**. Similarly, there should be no need for heavy-weight databases. Instead, looqs tries to squeeze out the most from simple approaches. In particular, it relies on sqlite.
|
||||
* **GUI & CLI**. Provide CLI interfaces and GUI interfaces
|
||||
* **Sandboxing**. As reading and rendering lots of formats naturally opens the door for security bugs, those tasks are offloaded to small, sandboxed sub-processes to mitigate the effect of exploited vulnerabilities.
|
||||
|
||||
|
||||
## Features
|
||||
- GUI, CLI interface
|
||||
- Indexing of file path and some metadata.
|
||||
- Indexing of file file content for FTS search. Currently: .pdf, odt, docx, plaintext.
|
||||
- Preview of file formats: Currently: .pdf, plaintext
|
||||
- Highlight searched terms.
|
||||
- Quickly open PDF viewer or text editor at location of preview
|
||||
- Search filters
|
||||
|
||||
## Supported platforms
|
||||
Linux (on amd64) is currently the main focus. Currently, I don't plan on supporting anything else and the sandboxing architecture does not make it likely. I suppose a version without sandboxing might be conceivable for other platforms, but I have no plans or resources to actively target anything but Linux at this point.
|
||||
|
||||
@ -34,15 +59,17 @@ Linux (on amd64) is currently the main focus. Currently, I don't plan on support
|
||||
GPLv3.
|
||||
|
||||
### Contributing
|
||||
For now, github issues and pull-requests are preferred, but you can also just email
|
||||
your patches or issues to: looqs at quitesimple.org
|
||||
Please see the [Contribution guidelines](CONTRIBUTING.md) file.
|
||||
|
||||
Please target the 'dev' branch in your pull request.
|
||||
## Documentation
|
||||
Please see [USAGE.md](USAGE.md) for the user manual. There is also [HACKING.md](HACKING.md) with more technical information.
|
||||
|
||||
|
||||
## Build
|
||||
|
||||
### Ubuntu 21.10/22.04
|
||||
|
||||
To build on Ubuntu and Debian, clone the repo and then run:
|
||||
```
|
||||
git submodule init
|
||||
git submodule update
|
||||
@ -53,9 +80,22 @@ make
|
||||
|
||||
The GUI is located in `gui/looqs-gui`, the binary for the CLI is in `cli/looqs`
|
||||
|
||||
|
||||
## Documentation
|
||||
Please see [USAGE.md](USAGE.md) for the user manual.
|
||||
|
||||
## Packages
|
||||
Coming soon™
|
||||
At this point, looqs is not in any official distro package repo, but I maintain some packages.
|
||||
|
||||
### Ubuntu 21.10/22.04
|
||||
Latest release can be installed using apt from the repo.
|
||||
```
|
||||
# First, obtain key, assume it's trusted.
|
||||
wget -O- https://repo.quitesimple.org/repo.quitesimple.org.asc | gpg --dearmor > repo.quitesimple.org-keyring.gpg
|
||||
cat repo.quitesimple.org-keyring.gpg | sudo tee -a /usr/share/keyrings/repo.quitesimple.org.gpg > /dev/null
|
||||
|
||||
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/repo.quitesimple.org.gpg] https://repo.quitesimple.org/debian/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/quitesimple.list
|
||||
sudo apt-get update
|
||||
sudo apt-get install looqs
|
||||
```
|
||||
|
||||
### Other distros
|
||||
I'll probably add a package for voidlinux at some point and maybe will provide a Gentoo ebuild. However, I would appreciate help for others distros. If you create a package, let me know!
|
||||
|
||||
As for distro-agnostic packages, I will also take a look into appimage / flatpak etc. and/or maybe just provide a self-contained archive.
|
||||
|
@ -29,8 +29,12 @@ void CommandAdd::indexerFinished()
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO maybe not 0 if keepGoing not given */
|
||||
emit finishedCmd(0);
|
||||
int ret = 0;
|
||||
if(!keepGoing && failedPathsCount > 0)
|
||||
{
|
||||
ret = 1;
|
||||
}
|
||||
emit finishedCmd(ret);
|
||||
}
|
||||
|
||||
int CommandAdd::handle(QStringList arguments)
|
||||
@ -40,15 +44,13 @@ int CommandAdd::handle(QStringList arguments)
|
||||
"Continue adding files, don't exit on first error. If this option is not given, looqs will "
|
||||
"exit asap, but it's possible that a few files will still be processed. "
|
||||
"Set -t 1 to avoid this behavior, but processing will be slower. "},
|
||||
{{"v", "verbose"}, "Print skipped and added files"},
|
||||
{{"t", "threads"}, "Number of threads to use.", "threads"}});
|
||||
|
||||
parser.addHelpOption();
|
||||
parser.addPositionalArgument("add", "Add paths to the index", "add [paths...]");
|
||||
|
||||
parser.process(arguments);
|
||||
bool keepGoing = parser.isSet("continue");
|
||||
bool verbose = parser.isSet("verbose");
|
||||
this->keepGoing = parser.isSet("continue");
|
||||
if(parser.isSet("threads"))
|
||||
{
|
||||
QString threadsCount = parser.value("threads");
|
||||
@ -70,17 +72,15 @@ int CommandAdd::handle(QStringList arguments)
|
||||
|
||||
indexer = new Indexer(*this->dbService);
|
||||
indexer->setTargetPaths(files.toVector());
|
||||
indexer->setKeepGoing(keepGoing);
|
||||
|
||||
connect(indexer, &Indexer::pathsCountChanged, this,
|
||||
[](int pathsCount) { Logger::info() << "Found paths: " << pathsCount << Qt::endl; });
|
||||
|
||||
connect(indexer, &Indexer::indexProgress, this,
|
||||
[](int pathsCount, unsigned int added, unsigned int skipped, unsigned int failed, unsigned int totalCount)
|
||||
{ Logger::info() << "Processed files: " << pathsCount << Qt::endl; });
|
||||
connect(indexer, &Indexer::finished, this, &CommandAdd::indexerFinished);
|
||||
|
||||
/* TODO: keepGoing, verbose */
|
||||
|
||||
this->autoFinish = false;
|
||||
indexer->beginIndexing();
|
||||
|
||||
|
@ -10,6 +10,7 @@ class CommandAdd : public Command
|
||||
private:
|
||||
SaveFileResult addFile(QString path);
|
||||
Indexer *indexer;
|
||||
bool keepGoing = true;
|
||||
|
||||
protected:
|
||||
public:
|
||||
|
@ -78,4 +78,4 @@ else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PW
|
||||
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../shared/debug/shared.lib
|
||||
else:unix: PRE_TARGETDEPS += $$OUT_PWD/../shared/libshared.a
|
||||
|
||||
RESOURCES = ../icon.svg
|
||||
RESOURCES = ../looqs.svg
|
||||
|
56
gui/main.cpp
56
gui/main.cpp
@ -23,25 +23,51 @@ void enableIpcSandbox()
|
||||
qCritical() << "Failed to init policy for sandbox";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
policy->namespace_options = EXILE_UNSHARE_NETWORK | EXILE_UNSHARE_USER;
|
||||
policy->namespace_options = EXILE_UNSHARE_USER | EXILE_UNSHARE_MOUNT | EXILE_UNSHARE_NETWORK;
|
||||
policy->no_new_privs = 1;
|
||||
policy->drop_caps = 1;
|
||||
policy->vow_promises =
|
||||
exile_vows_from_str("thread cpath wpath rpath unix stdio prot_exec proc shm fsnotify ioctl error");
|
||||
policy->vow_promises = exile_vows_from_str("thread cpath rpath unix stdio proc error");
|
||||
policy->mount_path_policies_to_chroot = 1;
|
||||
|
||||
QString ipcSocketPath = Common::ipcSocketPath();
|
||||
QFileInfo info{ipcSocketPath};
|
||||
QString ipcSocketPathDir = info.absolutePath();
|
||||
std::string stdIpcSocketPath = ipcSocketPathDir.toStdString();
|
||||
|
||||
exile_append_path_policies(policy, EXILE_FS_ALLOW_ALL_READ, "/");
|
||||
exile_append_path_policies(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_ALL_WRITE, stdIpcSocketPath.c_str());
|
||||
/* we only need the 'server' side of the 'unix' vow (for unix sockets)'. The process
|
||||
* has no business to connect anywhere.
|
||||
*
|
||||
* Maybe this case should be handled by exile at some point, but for now deal with it here */
|
||||
exile_append_syscall_policy(policy, EXILE_SYS(connect), EXILE_SYSCALL_DENY_RET_ERROR, NULL, 0);
|
||||
|
||||
/* ALLOW_EXEC is needed for fallback, not in landlock mode. It does not allow executing anything though here
|
||||
* due to the vows */
|
||||
exile_append_path_policies(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_EXEC, "/");
|
||||
exile_append_path_policies(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_ALL_WRITE | EXILE_FS_ALLOW_EXEC,
|
||||
stdIpcSocketPath.c_str());
|
||||
int ret = exile_enable_policy(policy);
|
||||
if(ret != 0)
|
||||
{
|
||||
qDebug() << "Failed to establish sandbox";
|
||||
qDebug() << "Failed to establish sandbox" << Qt::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Arguments are irrelevant for sandbox test, just want to silence analyzer/compiler warnings */
|
||||
ret = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(ret != -1 || errno != EACCES)
|
||||
{
|
||||
qCritical() << "Sandbox sanity check failed" << Qt::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
const struct sockaddr *addr = {};
|
||||
ret = connect(3, addr, sizeof(*addr));
|
||||
if(ret != -1 || errno != EACCES)
|
||||
{
|
||||
qCritical() << "Sandbox sanity check failed" << Qt::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
exile_free_policy(policy);
|
||||
}
|
||||
|
||||
@ -54,14 +80,21 @@ int main(int argc, char *argv[])
|
||||
if(arg == "ipc")
|
||||
{
|
||||
Common::setupAppInfo();
|
||||
enableIpcSandbox();
|
||||
QApplication a(argc, argv);
|
||||
if(Common::noSandboxModeRequested())
|
||||
{
|
||||
qInfo() << "Launching with no sandbox!" << Qt::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
enableIpcSandbox();
|
||||
}
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
IpcServer *ipcserver = new IpcServer();
|
||||
qDebug() << "Launching IPC Server";
|
||||
if(!ipcserver->startSpawner(socketPath))
|
||||
{
|
||||
qCritical() << "Error failed to spawn";
|
||||
qCritical() << "Error failed to spawn" << Qt::endl;
|
||||
return 1;
|
||||
}
|
||||
qDebug() << "Launched IPC Server";
|
||||
@ -109,7 +142,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
Common::setupAppInfo();
|
||||
QCommandLineParser parser;
|
||||
parser.addOption({{"s", "no-sandbox"}, "Disable sandboxing"});
|
||||
QStringList appArgs;
|
||||
for(int i = 0; i < argc; i++)
|
||||
{
|
||||
@ -117,6 +149,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
parser.parse(appArgs);
|
||||
|
||||
QApplication a(argc, argv);
|
||||
try
|
||||
{
|
||||
Common::ensureConfigured();
|
||||
@ -127,8 +160,7 @@ int main(int argc, char *argv[])
|
||||
QMessageBox::critical(nullptr, "Error", e.message);
|
||||
return 1;
|
||||
}
|
||||
QApplication a(argc, argv);
|
||||
a.setWindowIcon(QIcon(":/icon.svg"));
|
||||
a.setWindowIcon(QIcon(":/looqs.svg"));
|
||||
QObject::connect(&a, &QApplication::aboutToQuit, &process, &QProcess::kill);
|
||||
|
||||
qRegisterMetaType<QVector<SearchResult>>("QVector<SearchResult>");
|
||||
|
@ -192,12 +192,6 @@ void MainWindow::connectSignals()
|
||||
|
||||
QMessageBox::about(this, "About looqs", html);
|
||||
});
|
||||
connect(ui->menuOpenConfigInTextEditorAction, &QAction::triggered, this,
|
||||
[this](bool checked)
|
||||
{
|
||||
QSettings setting;
|
||||
QDesktopServices::openUrl(setting.fileName());
|
||||
});
|
||||
connect(ui->menuAboutQtAction, &QAction::triggered, this,
|
||||
[this](bool checked) { QMessageBox::aboutQt(this, "About Qt"); });
|
||||
connect(ui->menuSyncIndexAction, &QAction::triggered, this, &MainWindow::startIndexSync);
|
||||
@ -215,6 +209,7 @@ void MainWindow::connectSignals()
|
||||
});
|
||||
connect(this, &MainWindow::beginIndexSync, indexSyncer, &IndexSyncer::sync);
|
||||
connect(&this->progressDialog, &QProgressDialog::canceled, indexSyncer, &IndexSyncer::cancel);
|
||||
connect(ui->btnSaveSettings, &QPushButton::clicked, this, &MainWindow::saveSettings);
|
||||
}
|
||||
|
||||
void MainWindow::startIndexSync()
|
||||
@ -236,6 +231,7 @@ void MainWindow::startIndexSync()
|
||||
|
||||
emit beginIndexSync();
|
||||
}
|
||||
|
||||
void MainWindow::spinPreviewPageValueChanged(int val)
|
||||
{
|
||||
makePreviews(val);
|
||||
@ -253,6 +249,7 @@ void MainWindow::startIndexing()
|
||||
|
||||
ui->previewsTab->setEnabled(false);
|
||||
ui->resultsTab->setEnabled(false);
|
||||
ui->settingsTab->setEnabled(false);
|
||||
ui->txtPathScanAdd->setEnabled(false);
|
||||
ui->txtSearch->setEnabled(false);
|
||||
ui->previewProcessBar->setValue(0);
|
||||
@ -289,6 +286,7 @@ void MainWindow::finishIndexing()
|
||||
ui->btnStartIndexing->setText("Start indexing");
|
||||
ui->previewsTab->setEnabled(true);
|
||||
ui->resultsTab->setEnabled(true);
|
||||
ui->settingsTab->setEnabled(true);
|
||||
ui->txtPathScanAdd->setEnabled(true);
|
||||
ui->txtSearch->setEnabled(true);
|
||||
}
|
||||
@ -351,6 +349,49 @@ void MainWindow::tabChanged()
|
||||
makePreviews(ui->spinPreviewPage->value());
|
||||
}
|
||||
}
|
||||
/* Settings tab active */
|
||||
if(ui->tabWidget->currentIndex() == 3)
|
||||
{
|
||||
initSettingsTabs();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::initSettingsTabs()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
QString pdfViewerCmd = settings.value(SETTINGS_KEY_PDFVIEWER).toString();
|
||||
QString excludedPaths = Common::excludedPaths().join(';');
|
||||
QString mountPaths = Common::mountPaths().join(';');
|
||||
QString databasePath = Common::databasePath();
|
||||
int numPagesPerPreview = settings.value(SETTINGS_KEY_PREVIEWSPERPAGE, 20).toInt();
|
||||
|
||||
ui->txtSettingPdfPreviewerCmd->setText(pdfViewerCmd);
|
||||
ui->txtSettingIgnoredPaths->setText(excludedPaths);
|
||||
ui->txtSettingMountPaths->setText(mountPaths);
|
||||
ui->spinSettingNumerPerPages->setValue(numPagesPerPreview);
|
||||
ui->txtSettingDatabasePath->setText(databasePath);
|
||||
}
|
||||
|
||||
void MainWindow::saveSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
QString pdfViewerCmd = ui->txtSettingPdfPreviewerCmd->text();
|
||||
QStringList excludedPaths = ui->txtSettingIgnoredPaths->text().split(';');
|
||||
QStringList mountPaths = ui->txtSettingMountPaths->text().split(';');
|
||||
QString databasePath = ui->txtSettingDatabasePath->text();
|
||||
|
||||
settings.setValue(SETTINGS_KEY_PDFVIEWER, pdfViewerCmd);
|
||||
settings.setValue(SETTINGS_KEY_EXCLUDEDPATHS, excludedPaths);
|
||||
settings.setValue(SETTINGS_KEY_MOUNTPATHS, mountPaths);
|
||||
settings.setValue(SETTINGS_KEY_PREVIEWSPERPAGE, ui->spinSettingNumerPerPages->value());
|
||||
settings.setValue(SETTINGS_KEY_DBPATH, databasePath);
|
||||
|
||||
settings.sync();
|
||||
|
||||
QProcess::startDetached(qApp->arguments()[0], qApp->arguments().mid(1));
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
void MainWindow::previewReceived(QSharedPointer<PreviewResult> preview, unsigned int previewGeneration)
|
||||
@ -389,7 +430,7 @@ void MainWindow::lineEditReturnPressed()
|
||||
ui->lblSearchResults->setText("Invalid paranthesis");
|
||||
return;
|
||||
}
|
||||
if(indexerTabActive())
|
||||
if(ui->tabWidget->currentIndex() > 1)
|
||||
{
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
@ -454,6 +495,11 @@ void MainWindow::handleSearchResults(const QVector<SearchResult> &results)
|
||||
bool exists = pathInfo.exists();
|
||||
if(exists)
|
||||
{
|
||||
if(!result.wasContentSearch)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!pathInfo.suffix().contains("htm")) // hack until we can preview them properly...
|
||||
{
|
||||
if(PreviewGenerator::get(pathInfo) != nullptr)
|
||||
@ -502,7 +548,7 @@ void MainWindow::makePreviews(int page)
|
||||
scaleText.chop(1);
|
||||
|
||||
QVector<QString> wordsToHighlight;
|
||||
QRegularExpression extractor(R"#("([^"]*)"|(\w+))#");
|
||||
QRegularExpression extractor(R"#("([^"]*)"|((\p{L}|\p{N})+))#");
|
||||
for(const Token &token : this->contentSearchQuery.getTokens())
|
||||
{
|
||||
if(token.type == FILTER_CONTENT_CONTAINS)
|
||||
|
@ -61,6 +61,7 @@ class MainWindow : public QMainWindow
|
||||
void openDocument(QString path, int num);
|
||||
void openFile(QString path);
|
||||
unsigned int currentPreviewGeneration = 1;
|
||||
void initSettingsTabs();
|
||||
private slots:
|
||||
void lineEditReturnPressed();
|
||||
void treeSearchItemActivated(QTreeWidgetItem *item, int i);
|
||||
@ -73,6 +74,7 @@ class MainWindow : public QMainWindow
|
||||
void finishIndexing();
|
||||
void addPathToIndex();
|
||||
void startIndexSync();
|
||||
void saveSettings();
|
||||
|
||||
signals:
|
||||
void startIpcPreviews(RenderConfig config, const QVector<RenderTarget> &targets);
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1221</width>
|
||||
<height>709</height>
|
||||
<width>1280</width>
|
||||
<height>736</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -27,7 +27,7 @@
|
||||
<enum>QTabWidget::South</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="resultsTab">
|
||||
<attribute name="title">
|
||||
@ -81,8 +81,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1185</width>
|
||||
<height>419</height>
|
||||
<width>1244</width>
|
||||
<height>446</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||
@ -344,6 +344,145 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="settingsTab">
|
||||
<attribute name="title">
|
||||
<string>Settings</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupPdfSettings">
|
||||
<property name="title">
|
||||
<string>PDF Viewer</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Command to open PDF pages in (%f = file path; %p = page number)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="txtSettingPdfPreviewerCmd"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupMountPaths">
|
||||
<property name="title">
|
||||
<string>Mount paths</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblMountPaths">
|
||||
<property name="text">
|
||||
<string>Path prefixes of files that should not be removed during sync, even if they cannot be accessed (e . g. files indexed on external disks) . Separated by ;</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="txtSettingMountPaths"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Ignored paths</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Path prefixes that should always be ignored during indexing (will be applied before the ignore patterns). Separated by ;</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="txtSettingIgnoredPaths"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupSettingDatabasePath">
|
||||
<property name="title">
|
||||
<string>Database path</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblSettingDatabasePath">
|
||||
<property name="text">
|
||||
<string>Path of the database. Note: Changing it here will create an empty, new database. The old will not be moved. </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="txtSettingDatabasePath"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="Misc">
|
||||
<property name="title">
|
||||
<string>Misc</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Max number of previews per 'page' in 'Previews' tab: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinSettingNumerPerPages"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnSaveSettings">
|
||||
<property name="text">
|
||||
<string>Save settings and restart</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -368,7 +507,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1221</width>
|
||||
<width>1280</width>
|
||||
<height>35</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -376,7 +515,6 @@
|
||||
<property name="title">
|
||||
<string>looqs</string>
|
||||
</property>
|
||||
<addaction name="menuOpenConfigInTextEditorAction"/>
|
||||
<addaction name="menuSyncIndexAction"/>
|
||||
<addaction name="menuAboutAction"/>
|
||||
<addaction name="menuAboutQtAction"/>
|
||||
@ -389,11 +527,6 @@
|
||||
<string>About</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="menuOpenConfigInTextEditorAction">
|
||||
<property name="text">
|
||||
<string>Open config in text editor</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="menuAboutQtAction">
|
||||
<property name="text">
|
||||
<string>About Qt</string>
|
||||
|
@ -1,6 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Name=looqs
|
||||
Exec=/usr/bin/looqs-gui
|
||||
Exec=looqs-gui
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Icon=looqs
|
||||
|
Voor Breedte: | Hoogte: | Grootte: 13 KiB Na Breedte: | Hoogte: | Grootte: 13 KiB |
@ -14,12 +14,6 @@
|
||||
#include "databasefactory.h"
|
||||
#include "logger.h"
|
||||
|
||||
#define SETTINGS_KEY_DBPATH "dbpath"
|
||||
#define SETTINGS_KEY_FIRSTRUN "firstrun"
|
||||
#define SETTINGS_KEY_IPCSOCKETPATH "ipcsocketpath"
|
||||
#define SETTINGS_KEY_PDFVIEWER "pdfviewer"
|
||||
#define SETTINGS_KEY_EXCLUDEDPATHS "excludedpaths"
|
||||
|
||||
inline void initResources()
|
||||
{
|
||||
Q_INIT_RESOURCE(migrations);
|
||||
@ -90,10 +84,10 @@ void Common::setPdfViewer()
|
||||
void Common::ensureConfigured()
|
||||
{
|
||||
QSettings settings;
|
||||
QVariant firstRun = settings.value(SETTINGS_KEY_FIRSTRUN);
|
||||
if(!firstRun.isValid())
|
||||
QString dbpath = databasePath();
|
||||
if(dbpath == "")
|
||||
{
|
||||
QString dbpath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
||||
dbpath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
||||
QDir dir;
|
||||
if(!dir.exists(dbpath))
|
||||
{
|
||||
@ -103,38 +97,34 @@ void Common::ensureConfigured()
|
||||
}
|
||||
}
|
||||
dbpath += "/looqs.sqlite";
|
||||
}
|
||||
if(!QFile::exists(dbpath))
|
||||
{
|
||||
if(!initSqliteDatabase(dbpath))
|
||||
{
|
||||
throw LooqsGeneralException("Failed to initialize sqlite database");
|
||||
}
|
||||
|
||||
settings.setValue(SETTINGS_KEY_FIRSTRUN, false);
|
||||
settings.setValue(SETTINGS_KEY_DBPATH, dbpath);
|
||||
setPdfViewer();
|
||||
}
|
||||
else
|
||||
DatabaseFactory factory{dbpath};
|
||||
auto db = factory.forCurrentThread();
|
||||
DBMigrator migrator{db};
|
||||
if(migrator.migrationNeeded())
|
||||
{
|
||||
|
||||
QString dbpath = databasePath();
|
||||
if(!QFile::exists(dbpath))
|
||||
{
|
||||
throw LooqsGeneralException("Database " + dbpath + " was not found");
|
||||
}
|
||||
DatabaseFactory factory{dbpath};
|
||||
auto db = factory.forCurrentThread();
|
||||
DBMigrator migrator{db};
|
||||
if(migrator.migrationNeeded())
|
||||
{
|
||||
QFile out;
|
||||
out.open(stderr, QIODevice::WriteOnly);
|
||||
Logger migrationLogger{&out};
|
||||
migrationLogger << "Database is being upgraded, please be patient..." << Qt::endl;
|
||||
QObject::connect(&migrator, &DBMigrator::migrationDone,
|
||||
[&migrationLogger](uint32_t migration)
|
||||
{ migrationLogger << "Progress: Successfully migrated to: " << migration << Qt::endl; });
|
||||
migrator.performMigrations();
|
||||
migrationLogger << "Database upgraded successfully" << Qt::endl;
|
||||
}
|
||||
QFile out;
|
||||
out.open(stderr, QIODevice::WriteOnly);
|
||||
Logger migrationLogger{&out};
|
||||
migrationLogger << "Database is being upgraded, please be patient..." << Qt::endl;
|
||||
QObject::connect(&migrator, &DBMigrator::migrationDone,
|
||||
[&migrationLogger](uint32_t migration)
|
||||
{ migrationLogger << "Progress: Successfully migrated to: " << migration << Qt::endl; });
|
||||
migrator.performMigrations();
|
||||
migrationLogger << "Database upgraded successfully" << Qt::endl;
|
||||
}
|
||||
QVariant pdfViewer = settings.value(SETTINGS_KEY_PDFVIEWER);
|
||||
if(!pdfViewer.isValid())
|
||||
{
|
||||
setPdfViewer();
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,6 +146,16 @@ QString Common::databasePath()
|
||||
return env;
|
||||
}
|
||||
|
||||
bool Common::noSandboxModeRequested()
|
||||
{
|
||||
QString env = getenv("LOOQS_DISABLE_SANDBOX");
|
||||
if(env == "1")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString Common::ipcSocketPath()
|
||||
{
|
||||
return "/tmp/.looqs/looqs-ipc-socket";
|
||||
@ -165,19 +165,44 @@ QString Common::ipcSocketPath()
|
||||
// return settings.value(SETTINGS_KEY_IPCSOCKETPATH, "/tmp/.looqs/looqs-ipc-socket").toString();
|
||||
}
|
||||
|
||||
static QStringList excludedPaths = {"/proc", "/sys", "/dev", "/tmp", "/var/run", "/run"};
|
||||
|
||||
QStringList Common::excludedPaths()
|
||||
{
|
||||
static int ran = false;
|
||||
static QStringList excludedPaths;
|
||||
if(!ran)
|
||||
{
|
||||
QSettings settings;
|
||||
QStringList userExcludedPaths = settings.value(SETTINGS_KEY_EXCLUDEDPATHS).toStringList();
|
||||
QStringList defaults{"/proc", "/sys", "/dev", "/tmp", "/var/run", "/run"};
|
||||
excludedPaths = settings.value(SETTINGS_KEY_EXCLUDEDPATHS, defaults).toStringList();
|
||||
ran = true;
|
||||
::excludedPaths.append(userExcludedPaths);
|
||||
}
|
||||
return ::excludedPaths;
|
||||
return excludedPaths;
|
||||
}
|
||||
|
||||
QStringList Common::mountPaths()
|
||||
{
|
||||
static int ran = false;
|
||||
static QStringList mountPaths;
|
||||
if(!ran)
|
||||
{
|
||||
QSettings settings;
|
||||
mountPaths = settings.value(SETTINGS_KEY_MOUNTPATHS, QStringList{"/media", "/mnt"}).toStringList();
|
||||
ran = true;
|
||||
}
|
||||
return mountPaths;
|
||||
}
|
||||
|
||||
bool Common::isMountPath(QString path)
|
||||
{
|
||||
QStringList mountPaths = Common::mountPaths();
|
||||
for(QString &mountPath : mountPaths)
|
||||
{
|
||||
if(path.startsWith(mountPath))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Common::isTextFile(QFileInfo fileInfo)
|
||||
|
@ -2,6 +2,14 @@
|
||||
#define COMMON_H
|
||||
#include <QCoreApplication>
|
||||
#include <QFileInfo>
|
||||
|
||||
#define SETTINGS_KEY_DBPATH "dbpath"
|
||||
#define SETTINGS_KEY_IPCSOCKETPATH "ipcsocketpath"
|
||||
#define SETTINGS_KEY_PDFVIEWER "pdfviewer"
|
||||
#define SETTINGS_KEY_EXCLUDEDPATHS "excludedpaths"
|
||||
#define SETTINGS_KEY_MOUNTPATHS "mountpaths"
|
||||
#define SETTINGS_KEY_PREVIEWSPERPAGE "previewsPerPage"
|
||||
|
||||
namespace Common
|
||||
{
|
||||
void setupAppInfo();
|
||||
@ -12,7 +20,10 @@ QString findInPath(QString needle);
|
||||
bool initSqliteDatabase(QString path);
|
||||
void ensureConfigured();
|
||||
QStringList excludedPaths();
|
||||
QStringList mountPaths();
|
||||
bool isTextFile(QFileInfo fileInfo);
|
||||
bool isMountPath(QString path);
|
||||
bool noSandboxModeRequested();
|
||||
QString versionText();
|
||||
} // namespace Common
|
||||
#endif
|
||||
|
@ -19,7 +19,21 @@ void Indexer::beginIndexing()
|
||||
QVector<QString> dirs;
|
||||
|
||||
WildcardMatcher wildcardMatcher;
|
||||
wildcardMatcher.setPatterns(this->ignorePattern);
|
||||
|
||||
QStringList ignoreList = this->ignorePattern;
|
||||
|
||||
for(QString &excludedPath : Common::excludedPaths())
|
||||
{
|
||||
QString pattern = excludedPath;
|
||||
if(!pattern.endsWith("/"))
|
||||
{
|
||||
pattern += "/";
|
||||
}
|
||||
pattern += "*";
|
||||
ignoreList.append(excludedPath);
|
||||
}
|
||||
ignoreList.append(this->ignorePattern);
|
||||
wildcardMatcher.setPatterns(ignoreList);
|
||||
for(QString &path : this->pathsToScan)
|
||||
{
|
||||
if(wildcardMatcher.match(path))
|
||||
@ -36,10 +50,14 @@ void Indexer::beginIndexing()
|
||||
this->filePathTargetsQueue.enqueue(path);
|
||||
}
|
||||
}
|
||||
this->dirScanner->setPaths(dirs);
|
||||
this->dirScanner->setIgnorePatterns(this->ignorePattern);
|
||||
|
||||
this->dirScanner->scan();
|
||||
if(!dirs.empty())
|
||||
{
|
||||
this->dirScanner->setPaths(dirs);
|
||||
this->dirScanner->setIgnorePatterns(ignoreList);
|
||||
|
||||
this->dirScanner->scan();
|
||||
}
|
||||
|
||||
this->workerCancellationToken.store(false, std::memory_order_seq_cst);
|
||||
launchWorker(this->filePathTargetsQueue, this->filePathTargetsQueue.remaining());
|
||||
@ -55,6 +73,16 @@ void Indexer::setTargetPaths(QVector<QString> pathsToScan)
|
||||
this->pathsToScan = pathsToScan;
|
||||
}
|
||||
|
||||
void Indexer::setVerbose(bool verbose)
|
||||
{
|
||||
this->verbose = verbose;
|
||||
}
|
||||
|
||||
void Indexer::setKeepGoing(bool keepGoing)
|
||||
{
|
||||
this->keepGoing = keepGoing;
|
||||
}
|
||||
|
||||
void Indexer::requestCancellation()
|
||||
{
|
||||
this->dirScanner->cancel();
|
||||
@ -68,7 +96,7 @@ IndexResult Indexer::getResult()
|
||||
|
||||
void Indexer::dirScanFinished()
|
||||
{
|
||||
Logger::info() << "Dir scan finished";
|
||||
Logger::info() << "Dir scan finished" << Qt::endl;
|
||||
if(!isRunning())
|
||||
{
|
||||
emit finished();
|
||||
@ -92,17 +120,24 @@ void Indexer::dirScanProgress(int current, int total)
|
||||
|
||||
void Indexer::processFileScanResult(FileScanResult result)
|
||||
{
|
||||
if(verbose)
|
||||
if(result.second == DBFAIL || result.second == PROCESSFAIL || result.second == NOTFOUND)
|
||||
{
|
||||
this->currentIndexResult.results.append(result);
|
||||
if(!keepGoing)
|
||||
{
|
||||
this->requestCancellation();
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(result.second == DBFAIL || result.second == PROCESSFAIL || result.second == NOTFOUND)
|
||||
if(verbose)
|
||||
{
|
||||
this->currentIndexResult.results.append(result);
|
||||
}
|
||||
}
|
||||
|
||||
if(result.second == OK)
|
||||
{
|
||||
++this->currentIndexResult.addedPaths;
|
||||
|
@ -67,6 +67,8 @@ class Indexer : public QObject
|
||||
void beginIndexing();
|
||||
void setIgnorePattern(QStringList ignorePattern);
|
||||
void setTargetPaths(QVector<QString> pathsToScan);
|
||||
void setVerbose(bool verbose);
|
||||
void setKeepGoing(bool keepGoing);
|
||||
|
||||
void requestCancellation();
|
||||
|
||||
|
@ -55,6 +55,11 @@ void IndexSyncer::sync()
|
||||
emit finished(totalUpdatesFilesCount, totalDeletedFilesCount, totalErroredFilesCount);
|
||||
return;
|
||||
}
|
||||
if(Common::isMountPath(fileData.absPath))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QFileInfo fileInfo(fileData.absPath);
|
||||
if(fileInfo.exists())
|
||||
{
|
||||
|
@ -23,12 +23,12 @@ QueryType LooqsQuery::getQueryType()
|
||||
return static_cast<QueryType>(tokensMask & COMBINED);
|
||||
}
|
||||
|
||||
bool LooqsQuery::hasContentSearch()
|
||||
bool LooqsQuery::hasContentSearch() const
|
||||
{
|
||||
return (this->getTokensMask() & FILTER_CONTENT) == FILTER_CONTENT;
|
||||
}
|
||||
|
||||
bool LooqsQuery::hasPathSearch()
|
||||
bool LooqsQuery::hasPathSearch() const
|
||||
{
|
||||
return (this->getTokensMask() & FILTER_PATH) == FILTER_PATH;
|
||||
}
|
||||
@ -180,8 +180,9 @@ LooqsQuery LooqsQuery::build(QString expression, TokenType loneWordsTokenType, b
|
||||
|
||||
QStringList loneWords;
|
||||
LooqsQuery result;
|
||||
QRegularExpression rx("((?<filtername>(\\.|\\w)+):(?<args>\\((?<innerargs>[^\\)]+)\\)|([\\w,])+)|(?<boolean>AND|OR)"
|
||||
"|(?<negation>!)|(?<bracket>\\(|\\))|(?<loneword>[\"\\w]+))");
|
||||
QRegularExpression rx(
|
||||
"((?<filtername>(\\.|\\w)+):(?<args>\\((?<innerargs>[^\\)]+)\\)|([\\p{L}\\p{N},])+)|(?<boolean>AND|OR)"
|
||||
"|(?<negation>!)|(?<bracket>\\(|\\))|(?<loneword>[\"\\p{L}\\p{N}]+))");
|
||||
QRegularExpressionMatchIterator i = rx.globalMatch(expression);
|
||||
auto previousWasBool = [&result] { return !result.tokens.empty() && ((result.tokens.last().type & BOOL) == BOOL); };
|
||||
auto previousWas = [&result](TokenType t) { return !result.tokens.empty() && (result.tokens.last().type == t); };
|
||||
|
@ -61,8 +61,8 @@ class LooqsQuery
|
||||
{
|
||||
this->limit = limit;
|
||||
}
|
||||
bool hasContentSearch();
|
||||
bool hasPathSearch();
|
||||
bool hasContentSearch() const;
|
||||
bool hasPathSearch() const;
|
||||
|
||||
void addSortCondition(SortCondition sc);
|
||||
static bool checkParanthesis(QString query);
|
||||
|
@ -27,10 +27,15 @@ static QMap<QString, Processor *> processors{
|
||||
|
||||
void SandboxedProcessor::enableSandbox(QString readablePath)
|
||||
{
|
||||
if(Common::noSandboxModeRequested())
|
||||
{
|
||||
qInfo() << "Sandbox is disabled!" << Qt::endl;
|
||||
return;
|
||||
}
|
||||
struct exile_policy *policy = exile_init_policy();
|
||||
if(policy == NULL)
|
||||
{
|
||||
qCritical() << "Could not init exile";
|
||||
qCritical() << "Could not init exile" << Qt::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
policy->namespace_options = EXILE_UNSHARE_NETWORK | EXILE_UNSHARE_USER;
|
||||
@ -38,6 +43,8 @@ void SandboxedProcessor::enableSandbox(QString readablePath)
|
||||
std::string readablePathLocation;
|
||||
if(!readablePath.isEmpty())
|
||||
{
|
||||
policy->namespace_options |= EXILE_UNSHARE_MOUNT;
|
||||
policy->mount_path_policies_to_chroot = 1;
|
||||
readablePathLocation = readablePath.toStdString();
|
||||
if(exile_append_path_policies(policy, EXILE_FS_ALLOW_ALL_READ, readablePathLocation.c_str()) != 0)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ class SearchResult
|
||||
public:
|
||||
FileData fileData;
|
||||
QVector<unsigned int> pages;
|
||||
bool wasContentSearch = false;
|
||||
};
|
||||
|
||||
#endif // SEARCHRESULT_H
|
||||
|
@ -213,6 +213,7 @@ QVector<SearchResult> SqliteSearch::search(const LooqsQuery &query)
|
||||
throw LooqsGeneralException("SQL Error: " + dbQuery.lastError().text());
|
||||
}
|
||||
|
||||
bool contentSearch = query.hasContentSearch();
|
||||
while(dbQuery.next())
|
||||
{
|
||||
SearchResult result;
|
||||
@ -229,6 +230,7 @@ QVector<SearchResult> SqliteSearch::search(const LooqsQuery &query)
|
||||
result.pages.append(page.toUInt());
|
||||
}
|
||||
}
|
||||
result.wasContentSearch = contentSearch;
|
||||
results.append(result);
|
||||
}
|
||||
return results;
|
||||
|
Submodule submodules/exile.h updated: bbbdfc44da...8f38dc4480
Verwijs in nieuw issue
Block a user