mirror of
https://github.com/simon987/sist2.git
synced 2025-04-21 19:26:45 +00:00
Compare commits
No commits in common. "ca845d80e88d27fe9b74d5c93f9f1fe5751f26e3" and "ca2e308d89077d419dbe1c2638fdfd348d62a3bc" have entirely different histories.
ca845d80e8
...
ca2e308d89
@ -134,7 +134,7 @@ export default {
|
||||
duration: this.taskDuration(row),
|
||||
time: moment.utc(row.started).local().format("dd, MMM Do YYYY, HH:mm:ss"),
|
||||
logs: null,
|
||||
status: [0,1].includes(row.return_code) ? "ok" : "failed",
|
||||
status: row.return_code === 0 ? "ok" : "failed",
|
||||
_row: row
|
||||
}));
|
||||
});
|
||||
|
@ -275,10 +275,7 @@ def check_es_version(es_url: str, insecure: bool):
|
||||
|
||||
|
||||
def start_frontend_(frontend: Sist2Frontend):
|
||||
frontend.web_options.indices = [
|
||||
os.path.join(DATA_FOLDER, db["jobs"][j].index_path)
|
||||
for j in frontend.jobs
|
||||
]
|
||||
frontend.web_options.indices = list(map(lambda j: db["jobs"][j].index_path, frontend.jobs))
|
||||
|
||||
backend_name = frontend.web_options.search_backend
|
||||
search_backend = db["search_backends"][backend_name]
|
||||
@ -357,7 +354,7 @@ def delete_search_backend(name: str):
|
||||
del db["search_backends"][name]
|
||||
|
||||
try:
|
||||
os.remove(os.path.join(DATA_FOLDER, backend.search_index))
|
||||
os.remove(backend.search_index)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -10,9 +10,7 @@ from jobs import Sist2Job
|
||||
|
||||
|
||||
def _check_schedule(db: PersistentState, run_job):
|
||||
jobs = list(db["jobs"])
|
||||
|
||||
for job in jobs:
|
||||
for job in db["jobs"]:
|
||||
job: Sist2Job
|
||||
|
||||
if job.schedule_enabled:
|
||||
|
@ -13,7 +13,7 @@ from uuid import uuid4, UUID
|
||||
from hexlib.db import PersistentState
|
||||
from pydantic import BaseModel
|
||||
|
||||
from config import logger, LOG_FOLDER, DATA_FOLDER
|
||||
from config import logger, LOG_FOLDER
|
||||
from notifications import Notifications
|
||||
from sist2 import ScanOptions, IndexOptions, Sist2
|
||||
from state import RUNNING_FRONTENDS, get_log_files_to_remove, delete_log_file
|
||||
@ -131,9 +131,7 @@ class Sist2ScanTask(Sist2Task):
|
||||
return_code = sist2.scan(self.job.scan_options, logs_cb=self.log_callback, set_pid_cb=set_pid)
|
||||
self.ended = datetime.utcnow()
|
||||
|
||||
is_ok = return_code in (0, 1)
|
||||
|
||||
if not is_ok:
|
||||
if return_code != 0:
|
||||
self._logger.error(json.dumps({"sist2-admin": f"Process returned non-zero exit code ({return_code})"}))
|
||||
logger.info(f"Task {self.display_name} failed ({return_code})")
|
||||
else:
|
||||
@ -146,7 +144,7 @@ class Sist2ScanTask(Sist2Task):
|
||||
logger.info(f"Completed {self.display_name} ({return_code=})")
|
||||
|
||||
# Remove old index
|
||||
if is_ok:
|
||||
if return_code == 0:
|
||||
if self.job.previous_index_path is not None and self.job.previous_index_path != self.job.index_path:
|
||||
self._logger.info(json.dumps({"sist2-admin": f"Remove {self.job.previous_index_path=}"}))
|
||||
try:
|
||||
@ -220,10 +218,7 @@ class Sist2IndexTask(Sist2Task):
|
||||
|
||||
logger.debug(f"Fetched search backend options for {backend_name}")
|
||||
|
||||
frontend.web_options.indices = [
|
||||
os.path.join(DATA_FOLDER, db["jobs"][j].index_path)
|
||||
for j in frontend.jobs
|
||||
]
|
||||
frontend.web_options.indices = map(lambda j: db["jobs"][j].index_path, frontend.jobs)
|
||||
|
||||
pid = sist2.web(frontend.web_options, search_backend, frontend.name)
|
||||
RUNNING_FRONTENDS[frontend_name] = pid
|
||||
@ -249,7 +244,7 @@ class TaskQueue:
|
||||
def _tasks_failed(self):
|
||||
done = set()
|
||||
|
||||
for row in self._db["task_done"].sql("WHERE return_code NOT IN (0,1)"):
|
||||
for row in self._db["task_done"].sql("WHERE return_code != 0"):
|
||||
done.add(uuid.UUID(row["id"]))
|
||||
|
||||
return done
|
||||
|
@ -49,7 +49,7 @@ class Sist2SearchBackend(BaseModel):
|
||||
def create_default(name: str, backend_type: SearchBackendType = SearchBackendType("elasticsearch")):
|
||||
return Sist2SearchBackend(
|
||||
name=name,
|
||||
search_index=f"search-index-{name.replace('/', '_')}.sist2",
|
||||
search_index=os.path.join(DATA_FOLDER, f"search-index-{name.replace('/', '_')}.sist2"),
|
||||
backend_type=backend_type
|
||||
)
|
||||
|
||||
@ -63,13 +63,10 @@ class IndexOptions(BaseModel):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def args(self, search_backend):
|
||||
absolute_path = os.path.join(DATA_FOLDER, self.path)
|
||||
|
||||
if search_backend.backend_type == SearchBackendType("sqlite"):
|
||||
search_index_absolute = os.path.join(DATA_FOLDER, search_backend.search_index)
|
||||
args = ["sqlite-index", absolute_path, "--search-index", search_index_absolute]
|
||||
args = ["sqlite-index", self.path, "--search-index", search_backend.search_index]
|
||||
else:
|
||||
args = ["index", absolute_path, f"--threads={search_backend.threads}",
|
||||
args = ["index", self.path, f"--threads={search_backend.threads}",
|
||||
f"--es-url={search_backend.es_url}",
|
||||
f"--es-index={search_backend.es_index}",
|
||||
f"--batch-size={search_backend.batch_size}"]
|
||||
@ -121,12 +118,9 @@ class ScanOptions(BaseModel):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def args(self):
|
||||
|
||||
output_path = os.path.join(DATA_FOLDER, self.output)
|
||||
|
||||
args = ["scan", self.path, f"--threads={self.threads}", f"--thumbnail-quality={self.thumbnail_quality}",
|
||||
f"--thumbnail-count={self.thumbnail_count}", f"--thumbnail-size={self.thumbnail_size}",
|
||||
f"--content-size={self.content_size}", f"--output={output_path}", f"--depth={self.depth}",
|
||||
f"--content-size={self.content_size}", f"--output={self.output}", f"--depth={self.depth}",
|
||||
f"--archive={self.archive}", f"--mem-buffer={self.mem_buffer}"]
|
||||
|
||||
if self.incremental:
|
||||
@ -241,7 +235,7 @@ class WebOptions(BaseModel):
|
||||
class Sist2:
|
||||
|
||||
def __init__(self, bin_path: str, data_directory: str):
|
||||
self.bin_path = bin_path
|
||||
self._bin_path = bin_path
|
||||
self._data_dir = data_directory
|
||||
|
||||
def index(self, options: IndexOptions, search_backend: Sist2SearchBackend, logs_cb):
|
||||
@ -254,7 +248,7 @@ class Sist2:
|
||||
search_backend.script_file = None
|
||||
|
||||
args = [
|
||||
self.bin_path,
|
||||
self._bin_path,
|
||||
*options.args(search_backend),
|
||||
"--json-logs",
|
||||
"--very-verbose"
|
||||
@ -275,10 +269,13 @@ class Sist2:
|
||||
def scan(self, options: ScanOptions, logs_cb, set_pid_cb):
|
||||
|
||||
if options.output is None:
|
||||
options.output = f"scan-{options.name.replace('/', '_')}-{datetime.utcnow()}.sist2"
|
||||
options.output = os.path.join(
|
||||
self._data_dir,
|
||||
f"scan-{options.name.replace('/', '_')}-{datetime.utcnow()}.sist2"
|
||||
)
|
||||
|
||||
args = [
|
||||
self.bin_path,
|
||||
self._bin_path,
|
||||
*options.args(),
|
||||
"--json-logs",
|
||||
"--very-verbose"
|
||||
@ -336,7 +333,7 @@ class Sist2:
|
||||
options.auth0_public_key_file = None
|
||||
|
||||
args = [
|
||||
self.bin_path,
|
||||
self._bin_path,
|
||||
*options.args(search_backend)
|
||||
]
|
||||
|
||||
|
@ -51,11 +51,11 @@
|
||||
#include <ctype.h>
|
||||
#include "git_hash.h"
|
||||
|
||||
#define VERSION "3.1.2"
|
||||
#define VERSION "3.1.1"
|
||||
static const char *const Version = VERSION;
|
||||
static const int VersionMajor = 3;
|
||||
static const int VersionMinor = 1;
|
||||
static const int VersionPatch = 2;
|
||||
static const int VersionPatch = 1;
|
||||
|
||||
#ifndef SIST_PLATFORM
|
||||
#define SIST_PLATFORM unknown
|
||||
|
Loading…
x
Reference in New Issue
Block a user