mirror of
https://github.com/simon987/sist2.git
synced 2025-04-21 19:26:45 +00:00
Compare commits
No commits in common. "648e4817c4e8217955e4e275c2afd2d9b50c0b66" and "c6fee7f6e24672bfa042964f45be3c84c0600d5d" have entirely different histories.
648e4817c4
...
c6fee7f6e2
@ -22,4 +22,3 @@ third-party/libscan/libscan-test-files/
|
|||||||
**/scan_a_test
|
**/scan_a_test
|
||||||
Dockerfile
|
Dockerfile
|
||||||
*.idx/
|
*.idx/
|
||||||
VERSION
|
|
||||||
|
54
.drone.yml
54
.drone.yml
@ -43,30 +43,30 @@ steps:
|
|||||||
- ./sist2-x64-linux
|
- ./sist2-x64-linux
|
||||||
- ./sist2-x64-linux-debug
|
- ./sist2-x64-linux-debug
|
||||||
|
|
||||||
---
|
#---
|
||||||
kind: pipeline
|
#kind: pipeline
|
||||||
type: docker
|
#type: docker
|
||||||
name: arm64
|
#name: arm64
|
||||||
|
#
|
||||||
platform:
|
#platform:
|
||||||
arch: arm64
|
# arch: arm64
|
||||||
|
#
|
||||||
steps:
|
#steps:
|
||||||
- name: build
|
# - name: build
|
||||||
image: simon987/sist2-build-arm64
|
# image: simon987/ubuntu_ci_arm
|
||||||
commands:
|
# commands:
|
||||||
- ./ci/build_arm64.sh
|
# - ./ci/build_arm64.sh
|
||||||
- name: scp files
|
# - name: scp files
|
||||||
image: appleboy/drone-scp
|
# image: appleboy/drone-scp
|
||||||
settings:
|
# settings:
|
||||||
host:
|
# host:
|
||||||
from_secret: SSH_HOST
|
# from_secret: SSH_HOST
|
||||||
port:
|
# port:
|
||||||
from_secret: SSH_PORT
|
# from_secret: SSH_PORT
|
||||||
user:
|
# user:
|
||||||
from_secret: SSH_USER
|
# from_secret: SSH_USER
|
||||||
key:
|
# key:
|
||||||
from_secret: SSH_KEY
|
# from_secret: SSH_KEY
|
||||||
target: /files/sist2/${DRONE_REPO_OWNER}_${DRONE_REPO_NAME}/arm_${DRONE_BRANCH}_${DRONE_BUILD_NUMBER}_${DRONE_COMMIT}/
|
# target: /files/sist2/${DRONE_REPO_OWNER}_${DRONE_REPO_NAME}/arm_${DRONE_BRANCH}_${DRONE_BUILD_NUMBER}_${DRONE_COMMIT}/
|
||||||
source:
|
# source:
|
||||||
- ./sist2-arm64-linux
|
# - ./sist2-arm64-linux
|
||||||
|
40
.github/ISSUE_TEMPLATE/bug_report.md
vendored
40
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,40 +0,0 @@
|
|||||||
---
|
|
||||||
name: "🐞 Bug Report"
|
|
||||||
about: Submit a bug report
|
|
||||||
title: ''
|
|
||||||
labels: bug
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Device Information (please complete the following information):**
|
|
||||||
- OS: `[e.g., Ubuntu 20.04, WSL2]`
|
|
||||||
- Deployment: `[Linux, Linux ARM64 or Docker]`
|
|
||||||
- Browser *(if relevant)*: `[e.g., chrome, safari]`
|
|
||||||
- SIST2 Version: `[e.g., v2.9.0]`
|
|
||||||
- Elasticsearch Version *(if relevant)* : ``
|
|
||||||
|
|
||||||
**Command with arguments**
|
|
||||||
<!-- `ex: "scan ~/Documents -o ./i2 --threads 3 -q 1.0` -->
|
|
||||||
|
|
||||||
**Describe the bug**
|
|
||||||
<!-- A clear and concise description of what the bug is. -->
|
|
||||||
|
|
||||||
**Steps To Reproduce**
|
|
||||||
Please be specific!
|
|
||||||
1. Go to '...'
|
|
||||||
2. Click on '....'
|
|
||||||
3. etc.
|
|
||||||
|
|
||||||
**Expected behavior**
|
|
||||||
<!-- A clear and concise description of what you expected to happen. -->
|
|
||||||
|
|
||||||
**Actual Behavior**
|
|
||||||
<!-- A clear and concise description of what actually happens. -->
|
|
||||||
|
|
||||||
**Screenshots**
|
|
||||||
<!-- If applicable, add screenshots to help explain your problem. -->
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
<!-- Add any other context about the problem here. If applicable, please include why you think the bug is occurring and/or troubleshooting you have already performed. -->
|
|
||||||
<!-- If the issue is related to the `scan` module, please attach the files necessary to reproduce the error or email them to me[at]simon987.net. -->
|
|
5
.github/ISSUE_TEMPLATE/config.yml
vendored
5
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -1,5 +0,0 @@
|
|||||||
blank_issues_enabled: false
|
|
||||||
contact_links:
|
|
||||||
- name: SIST2 Documentation
|
|
||||||
url: https://github.com/simon987/sist2/blob/master/docs/USAGE.md
|
|
||||||
about: Check out the SIST2 documentation for answers to common questions
|
|
18
.github/ISSUE_TEMPLATE/feature_request.md
vendored
18
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
name: "🚀 Feature Request"
|
|
||||||
about: Suggest an idea for SIST2
|
|
||||||
title: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
**Which SIST2 component is your Feature Request related to?**
|
|
||||||
<!-- e.g., Scan, Index, or Web? -->
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
<!-- A clear and concise description of what the problem is. e.g., "I'm always frustrated when [...]" -->
|
|
||||||
|
|
||||||
**What would you like to see happen?**
|
|
||||||
<!-- A clear and concise description of what you want to happen. -->
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
<!-- Add any other context or screenshots about the feature request here. -->
|
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,4 +17,3 @@ vgcore.*
|
|||||||
build/
|
build/
|
||||||
third-party/
|
third-party/
|
||||||
*.idx/
|
*.idx/
|
||||||
VERSION
|
|
@ -9,7 +9,9 @@ RUN strip sist2
|
|||||||
|
|
||||||
FROM ubuntu:20.10
|
FROM ubuntu:20.10
|
||||||
|
|
||||||
RUN apt update && apt install -y curl
|
RUN apt update
|
||||||
|
RUN apt install -y libglib2.0-0 libcurl4 libmagic1 libharfbuzz-bin libopenjp2-7 libarchive13 liblzma5 libzstd1 liblz4-1 \
|
||||||
|
curl libtiff5 libpng16-16 libpcre3
|
||||||
|
|
||||||
RUN mkdir -p /usr/share/tessdata && \
|
RUN mkdir -p /usr/share/tessdata && \
|
||||||
cd /usr/share/tessdata/ && \
|
cd /usr/share/tessdata/ && \
|
||||||
|
@ -1,28 +1 @@
|
|||||||
FROM simon987/sist2-build-arm64 as build
|
# TODO
|
||||||
MAINTAINER simon987 <me@simon987.net>
|
|
||||||
|
|
||||||
WORKDIR /build/
|
|
||||||
ADD . /build/
|
|
||||||
RUN cmake -DSIST_DEBUG=off -DBUILD_TESTS=off -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake .
|
|
||||||
RUN make -j$(nproc)
|
|
||||||
RUN strip sist2
|
|
||||||
|
|
||||||
FROM ubuntu:20.10
|
|
||||||
|
|
||||||
RUN apt update && apt install -y curl
|
|
||||||
|
|
||||||
RUN mkdir -p /usr/share/tessdata && \
|
|
||||||
cd /usr/share/tessdata/ && \
|
|
||||||
curl -o /usr/share/tessdata/hin.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/hin.traineddata &&\
|
|
||||||
curl -o /usr/share/tessdata/jpn.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/jpn.traineddata &&\
|
|
||||||
curl -o /usr/share/tessdata/eng.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/eng.traineddata &&\
|
|
||||||
curl -o /usr/share/tessdata/fra.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/fra.traineddata &&\
|
|
||||||
curl -o /usr/share/tessdata/rus.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/rus.traineddata &&\
|
|
||||||
curl -o /usr/share/tessdata/spa.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/spa.traineddata
|
|
||||||
|
|
||||||
COPY --from=build /build/sist2 /root/sist2
|
|
||||||
|
|
||||||
ENV LANG C.UTF-8
|
|
||||||
ENV LC_ALL C.UTF-8
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/sist2"]
|
|
34
README.md
34
README.md
@ -1,6 +1,6 @@
|
|||||||

|

|
||||||
[](https://www.codefactor.io/repository/github/simon987/sist2)
|
[](https://www.codefactor.io/repository/github/simon987/sist2)
|
||||||
[](https://files.simon987.net/.gate/sist2/simon987_sist2/)
|
[](https://files.simon987.net/sist2/simon987_sist2/)
|
||||||
|
|
||||||
**Demo**: [sist2.simon987.net](https://sist2.simon987.net/?i=Demo%20files)
|
**Demo**: [sist2.simon987.net](https://sist2.simon987.net/?i=Demo%20files)
|
||||||
|
|
||||||
@ -50,8 +50,8 @@ sist2 (Simple incremental search tool)
|
|||||||
```
|
```
|
||||||
1. Download sist2 executable
|
1. Download sist2 executable
|
||||||
1. Download the [latest sist2 release](https://github.com/simon987/sist2/releases) *
|
1. Download the [latest sist2 release](https://github.com/simon987/sist2/releases) *
|
||||||
1. *(or)* Download a [development snapshot](https://files.simon987.net/.gate/sist2/simon987_sist2/) *(Not recommended!)*
|
1. *(or)* Download a [development snapshot](https://files.simon987.net/sist2/simon987_sist2/) *(Not recommended!)*
|
||||||
1. *(or)* `docker pull simon987/sist2:2.10.3-x64-linux`
|
1. *(or)* `docker pull simon987/sist2:latest`
|
||||||
|
|
||||||
1. See [Usage guide](docs/USAGE.md)
|
1. See [Usage guide](docs/USAGE.md)
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ See [Usage guide](docs/USAGE.md) for more details
|
|||||||
|
|
||||||
## Format support
|
## Format support
|
||||||
|
|
||||||
File type | Library | Content | Thumbnail | Metadata
|
File type | Library | Content | Thumbnail | Metadata
|
||||||
:---|:---|:---|:---|:---
|
:---|:---|:---|:---|:---
|
||||||
pdf,xps,fb2,epub | MuPDF | text+ocr | yes | author, title |
|
pdf,xps,fb2,epub | MuPDF | text+ocr | yes | author, title |
|
||||||
cbz,cbr | *(none)* | - | yes | - |
|
cbz,cbr | *(none)* | - | yes | - |
|
||||||
@ -116,35 +116,15 @@ sist2 scan --ocr eng ~/Books/Textbooks/
|
|||||||
|
|
||||||
## Build from source
|
## Build from source
|
||||||
|
|
||||||
You can compile **sist2** by yourself if you don't want to use the pre-compiled binaries
|
You can compile **sist2** by yourself if you don't want to use the pre-compiled binaries (GCC 7+ required).
|
||||||
|
|
||||||
### With docker (recommended)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone --recursive https://github.com/simon987/sist2/
|
|
||||||
cd sist2
|
|
||||||
docker build . -f ./Dockerfile -t my-sist2-image
|
|
||||||
docker run --rm my-sist2-image cat /root/sist2 > sist2-x64-linux
|
|
||||||
```
|
|
||||||
|
|
||||||
### On a linux computer
|
|
||||||
|
|
||||||
1. Install compile-time dependencies
|
1. Install compile-time dependencies
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
apt install gcc g++ python3 yasm ragel automake autotools-dev wget libtool libssl-dev curl zip unzip tar xorg-dev libglu1-mesa-dev libxcursor-dev libxml2-dev libxinerama-dev gettext nasm git
|
vcpkg install lmdb cjson glib libarchive[core,bzip2,libxml2,lz4,lzma,lzo] pthread tesseract libxml2 ffmpeg zstd gtest mongoose libmagic libraw curl[core,ssl] jbig2dec brotli libmupdf
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Apply vcpkg patches, as per [sist2-build](https://github.com/simon987/sist2-build) Dockerfile
|
2. Build
|
||||||
|
|
||||||
1. Install vcpkg dependencies
|
|
||||||
|
|
||||||
```bash
|
|
||||||
vcpkg install curl[core,openssl]
|
|
||||||
vcpkg install lmdb cjson glib brotli libarchive[core,bzip2,libxml2,lz4,lzma,lzo] pthread tesseract libxml2 libmupdf gtest mongoose libuuid libmagic libraw jasper lcms gumbo
|
|
||||||
```
|
|
||||||
|
|
||||||
1. Build
|
|
||||||
```bash
|
```bash
|
||||||
git clone --recursive https://github.com/simon987/sist2/
|
git clone --recursive https://github.com/simon987/sist2/
|
||||||
cmake -DSIST_DEBUG=off -DCMAKE_TOOLCHAIN_FILE=<VCPKG_ROOT>/scripts/buildsystems/vcpkg.cmake .
|
cmake -DSIST_DEBUG=off -DCMAKE_TOOLCHAIN_FILE=<VCPKG_ROOT>/scripts/buildsystems/vcpkg.cmake .
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
VCPKG_ROOT="/vcpkg"
|
VCPKG_ROOT="/vcpkg"
|
||||||
|
|
||||||
rm *.gz &>/dev/null
|
rm *.gz
|
||||||
|
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
|
||||||
@ -11,6 +11,7 @@ cmake -DSIST_DEBUG=off -DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystem
|
|||||||
make -j $(nproc)
|
make -j $(nproc)
|
||||||
strip sist2
|
strip sist2
|
||||||
./sist2 -v > VERSION
|
./sist2 -v > VERSION
|
||||||
|
cp sist2 Docker/
|
||||||
mv sist2 sist2-x64-linux
|
mv sist2 sist2-x64-linux
|
||||||
|
|
||||||
rm -rf CMakeFiles CMakeCache.txt
|
rm -rf CMakeFiles CMakeCache.txt
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
VCPKG_ROOT="/vcpkg"
|
VCPKG_ROOT="/vcpkg"
|
||||||
|
|
||||||
rm *.gz &>/dev/null
|
rm *.gz
|
||||||
|
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
|
||||||
rm -rf CMakeFiles CMakeCache.txt
|
rm -rf CMakeFiles CMakeCache.txt
|
||||||
cmake -DSIST_DEBUG=off -DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" .
|
cmake -DSIST_DEBUG=off -DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" .
|
||||||
make -j $(nproc)
|
make -j 4
|
||||||
strip sist2
|
strip sist2
|
||||||
mv sist2 sist2-arm64-linux
|
mv sist2 sist2-arm64-linux
|
@ -357,7 +357,8 @@ You can safely copy the `/tags/` database to another index.
|
|||||||
See [Automatic tagging](#automatic-tagging) for information about tag
|
See [Automatic tagging](#automatic-tagging) for information about tag
|
||||||
hierarchies and tag colors.
|
hierarchies and tag colors.
|
||||||
|
|
||||||
\* *It can take a few seconds to take effect in new search queries.*
|
\* *It can take a few seconds to take effect in new search queries, and the page needs
|
||||||
|
to be reloaded for the tags tab to update*
|
||||||
|
|
||||||
|
|
||||||
### Automatic tagging
|
### Automatic tagging
|
||||||
|
@ -232,7 +232,6 @@ int scan_args_validate(scan_args_t *args, int argc, const char **argv) {
|
|||||||
LOG_DEBUGF("cli.c", "arg tesseract_path=%s", args->tesseract_path)
|
LOG_DEBUGF("cli.c", "arg tesseract_path=%s", args->tesseract_path)
|
||||||
LOG_DEBUGF("cli.c", "arg exclude=%s", args->exclude_regex)
|
LOG_DEBUGF("cli.c", "arg exclude=%s", args->exclude_regex)
|
||||||
LOG_DEBUGF("cli.c", "arg fast=%d", args->fast)
|
LOG_DEBUGF("cli.c", "arg fast=%d", args->fast)
|
||||||
LOG_DEBUGF("cli.c", "arg fast_epub=%d", args->fast_epub)
|
|
||||||
LOG_DEBUGF("cli.c", "arg treemap_threshold=%f", args->treemap_threshold)
|
LOG_DEBUGF("cli.c", "arg treemap_threshold=%f", args->treemap_threshold)
|
||||||
LOG_DEBUGF("cli.c", "arg max_memory_buffer=%d", args->max_memory_buffer)
|
LOG_DEBUGF("cli.c", "arg max_memory_buffer=%d", args->max_memory_buffer)
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ typedef struct scan_args {
|
|||||||
double treemap_threshold;
|
double treemap_threshold;
|
||||||
int max_memory_buffer;
|
int max_memory_buffer;
|
||||||
int read_subtitles;
|
int read_subtitles;
|
||||||
int fast_epub;
|
|
||||||
} scan_args_t;
|
} scan_args_t;
|
||||||
|
|
||||||
scan_args_t *scan_args_create();
|
scan_args_t *scan_args_create();
|
||||||
|
@ -41,12 +41,6 @@ typedef struct {
|
|||||||
int fast;
|
int fast;
|
||||||
|
|
||||||
GHashTable *dbg_current_files;
|
GHashTable *dbg_current_files;
|
||||||
pthread_mutex_t dbg_current_files_mu;
|
|
||||||
|
|
||||||
int dbg_failed_files_count;
|
|
||||||
int dbg_skipped_files_count;
|
|
||||||
int dbg_excluded_files_count;
|
|
||||||
pthread_mutex_t dbg_file_counts_mu;
|
|
||||||
|
|
||||||
scan_arc_ctx_t arc_ctx;
|
scan_arc_ctx_t arc_ctx;
|
||||||
scan_comic_ctx_t comic_ctx;
|
scan_comic_ctx_t comic_ctx;
|
||||||
|
@ -41,10 +41,6 @@ int handle_entry(const char *filepath, const struct stat *info, int typeflag, st
|
|||||||
|
|
||||||
if (ScanCtx.exclude != NULL && EXCLUDED(filepath)) {
|
if (ScanCtx.exclude != NULL && EXCLUDED(filepath)) {
|
||||||
LOG_DEBUGF("walk.c", "Excluded: %s", filepath)
|
LOG_DEBUGF("walk.c", "Excluded: %s", filepath)
|
||||||
|
|
||||||
pthread_mutex_lock(&ScanCtx.dbg_file_counts_mu);
|
|
||||||
ScanCtx.dbg_excluded_files_count += 1;
|
|
||||||
pthread_mutex_unlock(&ScanCtx.dbg_file_counts_mu);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +51,6 @@ int handle_entry(const char *filepath, const struct stat *info, int typeflag, st
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_FILE_DESCRIPTORS 64
|
|
||||||
|
|
||||||
int walk_directory_tree(const char *dirpath) {
|
int walk_directory_tree(const char *dirpath) {
|
||||||
return nftw(dirpath, handle_entry, MAX_FILE_DESCRIPTORS, FTW_PHYS | FTW_DEPTH);
|
return nftw(dirpath, handle_entry, 15, FTW_PHYS);
|
||||||
}
|
}
|
||||||
|
65
src/main.c
65
src/main.c
@ -21,7 +21,7 @@
|
|||||||
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
|
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
|
||||||
|
|
||||||
|
|
||||||
static const char *const Version = "2.10.3";
|
static const char *const Version = "2.10.1";
|
||||||
static const char *const usage[] = {
|
static const char *const usage[] = {
|
||||||
"sist2 scan [OPTION]... PATH",
|
"sist2 scan [OPTION]... PATH",
|
||||||
"sist2 index [OPTION]... INDEX",
|
"sist2 index [OPTION]... INDEX",
|
||||||
@ -168,10 +168,7 @@ void initialize_scan_context(scan_args_t *args) {
|
|||||||
ScanCtx.arc_ctx.passphrase[0] = 0;
|
ScanCtx.arc_ctx.passphrase[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScanCtx.dbg_current_files = g_hash_table_new_full(g_int64_hash, g_int64_equal, NULL, NULL);
|
ScanCtx.dbg_current_files = g_hash_table_new(g_int64_hash, g_int64_equal);
|
||||||
pthread_mutex_init(&ScanCtx.dbg_current_files_mu, NULL);
|
|
||||||
|
|
||||||
pthread_mutex_init(&ScanCtx.dbg_file_counts_mu, NULL);
|
|
||||||
|
|
||||||
// Comic
|
// Comic
|
||||||
ScanCtx.comic_ctx.log = _log;
|
ScanCtx.comic_ctx.log = _log;
|
||||||
@ -191,7 +188,6 @@ void initialize_scan_context(scan_args_t *args) {
|
|||||||
ScanCtx.ebook_ctx.log = _log;
|
ScanCtx.ebook_ctx.log = _log;
|
||||||
ScanCtx.ebook_ctx.logf = _logf;
|
ScanCtx.ebook_ctx.logf = _logf;
|
||||||
ScanCtx.ebook_ctx.store = _store;
|
ScanCtx.ebook_ctx.store = _store;
|
||||||
ScanCtx.ebook_ctx.fast_epub_parse = args->fast_epub;
|
|
||||||
|
|
||||||
// Font
|
// Font
|
||||||
ScanCtx.font_ctx.enable_tn = args->size > 0;
|
ScanCtx.font_ctx.enable_tn = args->size > 0;
|
||||||
@ -252,7 +248,27 @@ void initialize_scan_context(scan_args_t *args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void load_incremental_index(const scan_args_t *args) {
|
void sist2_scan(scan_args_t *args) {
|
||||||
|
|
||||||
|
ScanCtx.mime_table = mime_get_mime_table();
|
||||||
|
ScanCtx.ext_table = mime_get_ext_table();
|
||||||
|
|
||||||
|
initialize_scan_context(args);
|
||||||
|
|
||||||
|
init_dir(ScanCtx.index.path);
|
||||||
|
|
||||||
|
char store_path[PATH_MAX];
|
||||||
|
snprintf(store_path, PATH_MAX, "%sthumbs", ScanCtx.index.path);
|
||||||
|
mkdir(store_path, S_IWUSR | S_IRUSR | S_IXUSR);
|
||||||
|
ScanCtx.index.store = store_create(store_path, STORE_SIZE_TN);
|
||||||
|
|
||||||
|
snprintf(store_path, PATH_MAX, "%smeta", ScanCtx.index.path);
|
||||||
|
mkdir(store_path, S_IWUSR | S_IRUSR | S_IXUSR);
|
||||||
|
ScanCtx.index.meta_store = store_create(store_path, STORE_SIZE_META);
|
||||||
|
|
||||||
|
scan_print_header();
|
||||||
|
|
||||||
|
if (args->incremental != NULL) {
|
||||||
ScanCtx.original_table = incremental_get_table();
|
ScanCtx.original_table = incremental_get_table();
|
||||||
ScanCtx.copy_table = incremental_get_table();
|
ScanCtx.copy_table = incremental_get_table();
|
||||||
|
|
||||||
@ -281,45 +297,14 @@ void load_incremental_index(const scan_args_t *args) {
|
|||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
LOG_INFOF("main.c", "Loaded %d items in to mtime table.", g_hash_table_size(ScanCtx.original_table))
|
LOG_INFOF("main.c", "Loaded %d items in to mtime table.", g_hash_table_size(ScanCtx.original_table))
|
||||||
}
|
|
||||||
|
|
||||||
void sist2_scan(scan_args_t *args) {
|
|
||||||
|
|
||||||
ScanCtx.mime_table = mime_get_mime_table();
|
|
||||||
ScanCtx.ext_table = mime_get_ext_table();
|
|
||||||
|
|
||||||
initialize_scan_context(args);
|
|
||||||
|
|
||||||
init_dir(ScanCtx.index.path);
|
|
||||||
|
|
||||||
char store_path[PATH_MAX];
|
|
||||||
snprintf(store_path, PATH_MAX, "%sthumbs", ScanCtx.index.path);
|
|
||||||
mkdir(store_path, S_IWUSR | S_IRUSR | S_IXUSR);
|
|
||||||
ScanCtx.index.store = store_create(store_path, STORE_SIZE_TN);
|
|
||||||
|
|
||||||
snprintf(store_path, PATH_MAX, "%smeta", ScanCtx.index.path);
|
|
||||||
mkdir(store_path, S_IWUSR | S_IRUSR | S_IXUSR);
|
|
||||||
ScanCtx.index.meta_store = store_create(store_path, STORE_SIZE_META);
|
|
||||||
|
|
||||||
scan_print_header();
|
|
||||||
|
|
||||||
if (args->incremental != NULL) {
|
|
||||||
load_incremental_index(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScanCtx.pool = tpool_create(args->threads, thread_cleanup, TRUE);
|
ScanCtx.pool = tpool_create(args->threads, thread_cleanup, TRUE);
|
||||||
tpool_start(ScanCtx.pool);
|
tpool_start(ScanCtx.pool);
|
||||||
int walk_ret = walk_directory_tree(ScanCtx.index.desc.root);
|
walk_directory_tree(ScanCtx.index.desc.root);
|
||||||
if (walk_ret == -1) {
|
|
||||||
LOG_FATALF("main.c", "walk_directory_tree() failed! %s (%d)", strerror(errno), errno)
|
|
||||||
}
|
|
||||||
tpool_wait(ScanCtx.pool);
|
tpool_wait(ScanCtx.pool);
|
||||||
tpool_destroy(ScanCtx.pool);
|
tpool_destroy(ScanCtx.pool);
|
||||||
|
|
||||||
LOG_DEBUGF("main.c", "Skipped files: %d", ScanCtx.dbg_skipped_files_count)
|
|
||||||
LOG_DEBUGF("main.c", "Excluded files: %d", ScanCtx.dbg_excluded_files_count)
|
|
||||||
LOG_DEBUGF("main.c", "Failed files: %d", ScanCtx.dbg_failed_files_count)
|
|
||||||
|
|
||||||
if (args->incremental != NULL) {
|
if (args->incremental != NULL) {
|
||||||
char dst_path[PATH_MAX];
|
char dst_path[PATH_MAX];
|
||||||
snprintf(store_path, PATH_MAX, "%sthumbs", args->incremental);
|
snprintf(store_path, PATH_MAX, "%sthumbs", args->incremental);
|
||||||
@ -441,7 +426,6 @@ void sist2_exec_script(exec_args_t *args) {
|
|||||||
index_descriptor_t desc = read_index_descriptor(descriptor_path);
|
index_descriptor_t desc = read_index_descriptor(descriptor_path);
|
||||||
|
|
||||||
IndexCtx.es_url = args->es_url;
|
IndexCtx.es_url = args->es_url;
|
||||||
IndexCtx.es_index = args->es_index;
|
|
||||||
|
|
||||||
LOG_DEBUGF("main.c", "descriptor version %s (%s)", desc.version, desc.type)
|
LOG_DEBUGF("main.c", "descriptor version %s (%s)", desc.version, desc.type)
|
||||||
|
|
||||||
@ -542,7 +526,6 @@ int main(int argc, const char *argv[]) {
|
|||||||
"Maximum memory buffer size per thread in MB for files inside archives "
|
"Maximum memory buffer size per thread in MB for files inside archives "
|
||||||
"(see USAGE.md). DEFAULT: 2000"),
|
"(see USAGE.md). DEFAULT: 2000"),
|
||||||
OPT_BOOLEAN(0, "read-subtitles", &scan_args->read_subtitles, "Read subtitles from media files."),
|
OPT_BOOLEAN(0, "read-subtitles", &scan_args->read_subtitles, "Read subtitles from media files."),
|
||||||
OPT_BOOLEAN(0, "fast-epub", &scan_args->fast_epub, "Faster but less accurate EPUB parsing (no thumbnails, metadata)"),
|
|
||||||
|
|
||||||
OPT_GROUP("Index options"),
|
OPT_GROUP("Index options"),
|
||||||
OPT_INTEGER('t', "threads", &common_threads, "Number of threads. DEFAULT=1"),
|
OPT_INTEGER('t', "threads", &common_threads, "Number of threads. DEFAULT=1"),
|
||||||
|
@ -43,9 +43,7 @@ void fs_reset(struct vfile *f) {
|
|||||||
|
|
||||||
void set_dbg_current_file(parse_job_t *job) {
|
void set_dbg_current_file(parse_job_t *job) {
|
||||||
unsigned long long pid = (unsigned long long) pthread_self();
|
unsigned long long pid = (unsigned long long) pthread_self();
|
||||||
pthread_mutex_lock(&ScanCtx.dbg_current_files_mu);
|
|
||||||
g_hash_table_replace(ScanCtx.dbg_current_files, GINT_TO_POINTER(pid), job);
|
g_hash_table_replace(ScanCtx.dbg_current_files, GINT_TO_POINTER(pid), job);
|
||||||
pthread_mutex_unlock(&ScanCtx.dbg_current_files_mu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse(void *arg) {
|
void parse(void *arg) {
|
||||||
@ -71,11 +69,6 @@ void parse(void *arg) {
|
|||||||
int inc_ts = incremental_get(ScanCtx.original_table, doc.path_md5);
|
int inc_ts = incremental_get(ScanCtx.original_table, doc.path_md5);
|
||||||
if (inc_ts != 0 && inc_ts == job->vfile.info.st_mtim.tv_sec) {
|
if (inc_ts != 0 && inc_ts == job->vfile.info.st_mtim.tv_sec) {
|
||||||
incremental_mark_file_for_copy(ScanCtx.copy_table, doc.path_md5);
|
incremental_mark_file_for_copy(ScanCtx.copy_table, doc.path_md5);
|
||||||
|
|
||||||
pthread_mutex_lock(&ScanCtx.dbg_file_counts_mu);
|
|
||||||
ScanCtx.dbg_skipped_files_count += 1;
|
|
||||||
pthread_mutex_unlock(&ScanCtx.dbg_file_counts_mu);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,10 +110,6 @@ void parse(void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CLOSE_FILE(job->vfile)
|
CLOSE_FILE(job->vfile)
|
||||||
|
|
||||||
pthread_mutex_lock(&ScanCtx.dbg_file_counts_mu);
|
|
||||||
ScanCtx.dbg_failed_files_count += 1;
|
|
||||||
pthread_mutex_unlock(&ScanCtx.dbg_file_counts_mu);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<nav class="navbar navbar-expand-lg">
|
<nav class="navbar navbar-expand-lg">
|
||||||
<a class="navbar-brand" href="/">sist2</a>
|
<a class="navbar-brand" href="/">sist2</a>
|
||||||
<span class="badge badge-pill version">2.10.3</span>
|
<span class="badge badge-pill version">2.10.1</span>
|
||||||
<span class="tagline">Lightning-fast file system indexer and search tool </span>
|
<span class="tagline">Lightning-fast file system indexer and search tool </span>
|
||||||
<a class="btn ml-auto" href="stats">Stats</a>
|
<a class="btn ml-auto" href="stats">Stats</a>
|
||||||
<button class="btn" type="button" data-toggle="modal" data-target="#settings" onclick="loadSettings()">Settings
|
<button class="btn" type="button" data-toggle="modal" data-target="#settings" onclick="loadSettings()">Settings
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<nav class="navbar navbar-expand-lg">
|
<nav class="navbar navbar-expand-lg">
|
||||||
<a class="navbar-brand" href="/">sist2</a>
|
<a class="navbar-brand" href="/">sist2</a>
|
||||||
<span class="badge badge-pill version">2.10.3</span>
|
<span class="badge badge-pill version">2.10.1</span>
|
||||||
<span class="tagline">Lightning-fast file system indexer and search tool </span>
|
<span class="tagline">Lightning-fast file system indexer and search tool </span>
|
||||||
<a style="margin-left: auto" class="btn" href="/">Back</a>
|
<a style="margin-left: auto" class="btn" href="/">Back</a>
|
||||||
<button class="btn" type="button" data-toggle="modal" data-target="#settings"
|
<button class="btn" type="button" data-toggle="modal" data-target="#settings"
|
||||||
|
26
src/tpool.c
26
src/tpool.c
@ -27,7 +27,6 @@ typedef struct tpool {
|
|||||||
int thread_cnt;
|
int thread_cnt;
|
||||||
int work_cnt;
|
int work_cnt;
|
||||||
int done_cnt;
|
int done_cnt;
|
||||||
int busy_cnt;
|
|
||||||
|
|
||||||
int free_arg;
|
int free_arg;
|
||||||
int stop;
|
int stop;
|
||||||
@ -57,7 +56,6 @@ void tpool_dump_debug_info(tpool_t *pool) {
|
|||||||
LOG_DEBUGF("tpool.c", "pool->thread_cnt = %d", pool->thread_cnt)
|
LOG_DEBUGF("tpool.c", "pool->thread_cnt = %d", pool->thread_cnt)
|
||||||
LOG_DEBUGF("tpool.c", "pool->work_cnt = %d", pool->work_cnt)
|
LOG_DEBUGF("tpool.c", "pool->work_cnt = %d", pool->work_cnt)
|
||||||
LOG_DEBUGF("tpool.c", "pool->done_cnt = %d", pool->done_cnt)
|
LOG_DEBUGF("tpool.c", "pool->done_cnt = %d", pool->done_cnt)
|
||||||
LOG_DEBUGF("tpool.c", "pool->busy_cnt = %d", pool->busy_cnt)
|
|
||||||
LOG_DEBUGF("tpool.c", "pool->stop = %d", pool->stop)
|
LOG_DEBUGF("tpool.c", "pool->stop = %d", pool->stop)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,10 +127,6 @@ static void *tpool_worker(void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tpool_work_t *work = tpool_work_get(pool);
|
tpool_work_t *work = tpool_work_get(pool);
|
||||||
if (work != NULL) {
|
|
||||||
pool->busy_cnt += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&(pool->work_mutex));
|
pthread_mutex_unlock(&(pool->work_mutex));
|
||||||
|
|
||||||
if (work != NULL) {
|
if (work != NULL) {
|
||||||
@ -149,7 +143,6 @@ static void *tpool_worker(void *arg) {
|
|||||||
|
|
||||||
pthread_mutex_lock(&(pool->work_mutex));
|
pthread_mutex_lock(&(pool->work_mutex));
|
||||||
if (work != NULL) {
|
if (work != NULL) {
|
||||||
pool->busy_cnt -= 1;
|
|
||||||
pool->done_cnt++;
|
pool->done_cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,14 +168,14 @@ static void *tpool_worker(void *arg) {
|
|||||||
void tpool_wait(tpool_t *pool) {
|
void tpool_wait(tpool_t *pool) {
|
||||||
LOG_INFO("tpool.c", "Waiting for worker threads to finish")
|
LOG_INFO("tpool.c", "Waiting for worker threads to finish")
|
||||||
pthread_mutex_lock(&(pool->work_mutex));
|
pthread_mutex_lock(&(pool->work_mutex));
|
||||||
while (TRUE) {
|
while (1) {
|
||||||
if (pool->done_cnt < pool->work_cnt) {
|
if (pool->done_cnt < pool->work_cnt) {
|
||||||
pthread_cond_wait(&(pool->working_cond), &(pool->work_mutex));
|
pthread_cond_wait(&(pool->working_cond), &(pool->work_mutex));
|
||||||
} else {
|
} else {
|
||||||
LOG_INFOF("tpool.c", "Received head=NULL signal, busy_cnt=%d", pool->busy_cnt);
|
usleep(500000);
|
||||||
|
if (pool->done_cnt == pool->work_cnt) {
|
||||||
if (pool->done_cnt == pool->work_cnt && pool->busy_cnt == 0) {
|
pool->stop = 1;
|
||||||
pool->stop = TRUE;
|
usleep(1000000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,16 +195,12 @@ void tpool_destroy(tpool_t *pool) {
|
|||||||
|
|
||||||
pthread_mutex_lock(&(pool->work_mutex));
|
pthread_mutex_lock(&(pool->work_mutex));
|
||||||
tpool_work_t *work = pool->work_head;
|
tpool_work_t *work = pool->work_head;
|
||||||
int count = 0;
|
|
||||||
while (work != NULL) {
|
while (work != NULL) {
|
||||||
tpool_work_t *tmp = work->next;
|
tpool_work_t *tmp = work->next;
|
||||||
free(work);
|
free(work);
|
||||||
work = tmp;
|
work = tmp;
|
||||||
count += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUGF("tpool.c", "Destroyed %d jobs", count);
|
|
||||||
|
|
||||||
pthread_cond_broadcast(&(pool->has_work_cond));
|
pthread_cond_broadcast(&(pool->has_work_cond));
|
||||||
pthread_mutex_unlock(&(pool->work_mutex));
|
pthread_mutex_unlock(&(pool->work_mutex));
|
||||||
|
|
||||||
@ -237,14 +226,13 @@ void tpool_destroy(tpool_t *pool) {
|
|||||||
* Create a thread pool
|
* Create a thread pool
|
||||||
* @param thread_cnt Worker threads count
|
* @param thread_cnt Worker threads count
|
||||||
*/
|
*/
|
||||||
tpool_t *tpool_create(int thread_cnt, void cleanup_func(), int free_arg) {
|
tpool_t *tpool_create(size_t thread_cnt, void cleanup_func(), int free_arg) {
|
||||||
|
|
||||||
tpool_t *pool = malloc(sizeof(tpool_t));
|
tpool_t *pool = malloc(sizeof(tpool_t));
|
||||||
pool->thread_cnt = thread_cnt;
|
pool->thread_cnt = thread_cnt;
|
||||||
pool->work_cnt = 0;
|
pool->work_cnt = 0;
|
||||||
pool->done_cnt = 0;
|
pool->done_cnt = 0;
|
||||||
pool->busy_cnt = 0;
|
pool->stop = 0;
|
||||||
pool->stop = FALSE;
|
|
||||||
pool->free_arg = free_arg;
|
pool->free_arg = free_arg;
|
||||||
pool->cleanup_func = cleanup_func;
|
pool->cleanup_func = cleanup_func;
|
||||||
pool->threads = calloc(sizeof(pthread_t), thread_cnt);
|
pool->threads = calloc(sizeof(pthread_t), thread_cnt);
|
||||||
|
@ -8,7 +8,7 @@ typedef struct tpool tpool_t;
|
|||||||
|
|
||||||
typedef void (*thread_func_t)(void *arg);
|
typedef void (*thread_func_t)(void *arg);
|
||||||
|
|
||||||
tpool_t *tpool_create(int num, void (*cleanup_func)(), int free_arg);
|
tpool_t *tpool_create(size_t num, void (*cleanup_func)(), int free_arg);
|
||||||
void tpool_start(tpool_t *pool);
|
void tpool_start(tpool_t *pool);
|
||||||
void tpool_destroy(tpool_t *pool);
|
void tpool_destroy(tpool_t *pool);
|
||||||
|
|
||||||
|
@ -178,9 +178,6 @@ void thumbnail(struct mg_connection *nc, struct mg_http_message *hm) {
|
|||||||
send_response_line(nc, 200, data_len, "Content-Type: image/jpeg");
|
send_response_line(nc, 200, data_len, "Content-Type: image/jpeg");
|
||||||
mg_send(nc, data, data_len);
|
mg_send(nc, data, data_len);
|
||||||
free(data);
|
free(data);
|
||||||
} else {
|
|
||||||
mg_http_reply(nc, 404, "Content-Type: text/plain;charset=utf-8\r\n", "Not found");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,10 +220,7 @@ void serve_file_from_url(cJSON *json, index_t *idx, struct mg_connection *nc) {
|
|||||||
dyn_buffer_t encoded = url_escape(url);
|
dyn_buffer_t encoded = url_escape(url);
|
||||||
dyn_buffer_write_char(&encoded, '\0');
|
dyn_buffer_write_char(&encoded, '\0');
|
||||||
|
|
||||||
char location_header[8192];
|
mg_http_reply(nc, 308, "Location: %s", encoded.buf);
|
||||||
snprintf(location_header, sizeof(location_header), "Location: %s\r\n", encoded.buf);
|
|
||||||
|
|
||||||
mg_http_reply(nc, 308, location_header, "");
|
|
||||||
dyn_buffer_destroy(&encoded);
|
dyn_buffer_destroy(&encoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +245,7 @@ void serve_file_from_disk(cJSON *json, index_t *idx, struct mg_connection *nc, s
|
|||||||
LOG_DEBUGF("serve.c", "Serving file from disk: %s", full_path)
|
LOG_DEBUGF("serve.c", "Serving file from disk: %s", full_path)
|
||||||
|
|
||||||
char disposition[8192];
|
char disposition[8192];
|
||||||
snprintf(disposition, sizeof(disposition), "Content-Disposition: inline; filename=\"%s%s%s\"\r\nAccept-Ranges: bytes\r\n",
|
snprintf(disposition, sizeof(disposition), "Content-Disposition: inline; filename=\"%s%s%s\"\r\n",
|
||||||
name, strlen(ext) == 0 ? "" : ".", ext);
|
name, strlen(ext) == 0 ? "" : ".", ext);
|
||||||
|
|
||||||
mg_http_serve_file(nc, hm, full_path, mime, disposition);
|
mg_http_serve_file(nc, hm, full_path, mime, disposition);
|
||||||
@ -537,7 +531,7 @@ int validate_auth(struct mg_connection *nc, struct mg_http_message *hm) {
|
|||||||
|
|
||||||
mg_http_creds(hm, user, sizeof(user), pass, sizeof(pass));
|
mg_http_creds(hm, user, sizeof(user), pass, sizeof(pass));
|
||||||
if (strcmp(user, WebCtx.auth_user) != 0 || strcmp(pass, WebCtx.auth_pass) != 0) {
|
if (strcmp(user, WebCtx.auth_user) != 0 || strcmp(pass, WebCtx.auth_pass) != 0) {
|
||||||
mg_http_reply(nc, 401, "WWW-Authenticate: Basic realm=\"sist2\"\r\n", "");
|
mg_http_reply(nc, 401, "WWW-Authenticate: Basic realm=\"sist2\"", "");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -550,6 +544,7 @@ static void ev_router(struct mg_connection *nc, int ev, void *ev_data, UNUSED(vo
|
|||||||
|
|
||||||
if (WebCtx.auth_enabled == TRUE) {
|
if (WebCtx.auth_enabled == TRUE) {
|
||||||
if (!validate_auth(nc, hm)) {
|
if (!validate_auth(nc, hm)) {
|
||||||
|
nc->is_closing = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -580,6 +575,7 @@ static void ev_router(struct mg_connection *nc, int ev, void *ev_data, UNUSED(vo
|
|||||||
stats_files(nc, hm);
|
stats_files(nc, hm);
|
||||||
} else if (mg_http_match_uri(hm, "/tag/*")) {
|
} else if (mg_http_match_uri(hm, "/tag/*")) {
|
||||||
if (WebCtx.tag_auth_enabled == TRUE && !validate_auth(nc, hm)) {
|
if (WebCtx.tag_auth_enabled == TRUE && !validate_auth(nc, hm)) {
|
||||||
|
nc->is_closing = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tag(nc, hm);
|
tag(nc, hm);
|
||||||
|
File diff suppressed because one or more lines are too long
2
third-party/libscan
vendored
2
third-party/libscan
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 413fb4bec79f8b8ad4611e9a75757f01af7d8667
|
Subproject commit 9be4f02851107edac65894a1fdde16a80cad43ac
|
Loading…
x
Reference in New Issue
Block a user