mirror of
https://github.com/simon987/sist2.git
synced 2025-12-14 07:49:06 +00:00
Compare commits
9 Commits
3.1.2
...
5a1a04629f
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a1a04629f | |||
| 242dd67416 | |||
| 54d902146a | |||
| 3b0ab3679a | |||
|
|
58ce0ef414 | ||
| f984baf7fd | |||
| ce242d1053 | |||
| 71deab7fa2 | |||
|
|
b0462f9378 |
@@ -187,6 +187,7 @@ class Sist2Index:
|
|||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self._descriptor["name"]
|
return self._descriptor["name"]
|
||||||
|
|
||||||
|
|
||||||
class WebOptions(BaseModel):
|
class WebOptions(BaseModel):
|
||||||
indices: List[str] = []
|
indices: List[str] = []
|
||||||
|
|
||||||
@@ -212,7 +213,8 @@ class WebOptions(BaseModel):
|
|||||||
f"--lang={self.lang}"]
|
f"--lang={self.lang}"]
|
||||||
|
|
||||||
if search_backend.backend_type == SearchBackendType("sqlite"):
|
if search_backend.backend_type == SearchBackendType("sqlite"):
|
||||||
args.append(f"--search-index={search_backend.search_index}")
|
search_index_absolute = os.path.join(DATA_FOLDER, search_backend.search_index)
|
||||||
|
args.append(f"--search-index={search_index_absolute}")
|
||||||
else:
|
else:
|
||||||
args.append(f"--es-url={search_backend.es_url}")
|
args.append(f"--es-url={search_backend.es_url}")
|
||||||
args.append(f"--es-index={search_backend.es_index}")
|
args.append(f"--es-index={search_backend.es_index}")
|
||||||
@@ -238,6 +240,7 @@ class WebOptions(BaseModel):
|
|||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
class Sist2:
|
class Sist2:
|
||||||
|
|
||||||
def __init__(self, bin_path: str, data_directory: str):
|
def __init__(self, bin_path: str, data_directory: str):
|
||||||
@@ -357,5 +360,3 @@ class Sist2:
|
|||||||
t_stdout.start()
|
t_stdout.start()
|
||||||
|
|
||||||
return proc.pid
|
return proc.pid
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ def get_log_files_to_remove(db: PersistentState, job_name: str, n: int):
|
|||||||
if row["name"].endswith(f"[{job_name}]"):
|
if row["name"].endswith(f"[{job_name}]"):
|
||||||
counter += 1
|
counter += 1
|
||||||
|
|
||||||
if counter > n:
|
if counter > n:
|
||||||
to_remove.append(row)
|
to_remove.append(row)
|
||||||
|
|
||||||
return to_remove
|
return to_remove
|
||||||
|
|
||||||
|
|||||||
@@ -531,8 +531,8 @@ class Sist2Api {
|
|||||||
size: 0
|
size: 0
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
const range = {
|
const range = {
|
||||||
min: res.aggregations.dateMin.value,
|
min: res.aggregations.dateMin.value / 1000,
|
||||||
max: res.aggregations.dateMax.value,
|
max: res.aggregations.dateMax.value / 1000,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (range.min == null) {
|
if (range.min == null) {
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ file_type_t get_file_type(unsigned int mime, size_t size, const char *filepath)
|
|||||||
} else if (IS_FONT(mime)) {
|
} else if (IS_FONT(mime)) {
|
||||||
return FILETYPE_FONT;
|
return FILETYPE_FONT;
|
||||||
} else if (ScanCtx.arc_ctx.mode != ARC_MODE_SKIP && (
|
} else if (ScanCtx.arc_ctx.mode != ARC_MODE_SKIP && (
|
||||||
IS_ARC(mime) ||
|
IS_ARC(mime) ||
|
||||||
(IS_ARC_FILTER(mime) && should_parse_filtered_file(filepath))
|
(IS_ARC_FILTER(mime) && should_parse_filtered_file(filepath))
|
||||||
)) {
|
)) {
|
||||||
return FILETYPE_ARCHIVE;
|
return FILETYPE_ARCHIVE;
|
||||||
} else if ((ScanCtx.ooxml_ctx.content_size > 0 || ScanCtx.media_ctx.tn_size > 0) && IS_DOC(mime)) {
|
} else if ((ScanCtx.ooxml_ctx.content_size > 0 || ScanCtx.media_ctx.tn_size > 0) && IS_DOC(mime)) {
|
||||||
return FILETYPE_OOXML;
|
return FILETYPE_OOXML;
|
||||||
@@ -155,19 +155,17 @@ void parse(parse_job_t *job) {
|
|||||||
doc->meta_head = NULL;
|
doc->meta_head = NULL;
|
||||||
doc->meta_tail = NULL;
|
doc->meta_tail = NULL;
|
||||||
doc->size = job->vfile.st_size;
|
doc->size = job->vfile.st_size;
|
||||||
doc->mtime = job->vfile.mtime;
|
doc->mtime = MAX(job->vfile.mtime, 0);
|
||||||
doc->mime = get_mime(job);
|
doc->mime = get_mime(job);
|
||||||
generate_doc_id(doc->filepath + ScanCtx.index.desc.root_len, doc->doc_id);
|
generate_doc_id(doc->filepath + ScanCtx.index.desc.root_len, doc->doc_id);
|
||||||
|
|
||||||
if (doc->mime == GET_MIME_ERROR_FATAL) {
|
if (doc->mime == GET_MIME_ERROR_FATAL) {
|
||||||
|
|
||||||
CLOSE_FILE(job->vfile)
|
CLOSE_FILE(job->vfile)
|
||||||
free(doc);
|
free(doc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (database_mark_document(ProcData.index_db, doc->doc_id, doc->mtime)) {
|
if (database_mark_document(ProcData.index_db, doc->doc_id, doc->mtime)) {
|
||||||
|
|
||||||
CLOSE_FILE(job->vfile)
|
CLOSE_FILE(job->vfile)
|
||||||
free(doc);
|
free(doc);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -248,9 +248,11 @@ void serve_file_from_disk(cJSON *json, index_t *idx, struct mg_connection *nc, s
|
|||||||
|
|
||||||
char mime_mapping[8192];
|
char mime_mapping[8192];
|
||||||
if (strlen(ext) == 0) {
|
if (strlen(ext) == 0) {
|
||||||
snprintf(mime_mapping, sizeof(mime_mapping), "%s=%s", full_path, mime);
|
snprintf(mime_mapping, sizeof(mime_mapping), "%s=%s%s",
|
||||||
|
full_path, mime, STR_STARTS_WITH_CONSTANT(mime, "text/") ? "; charset=utf8" : "");
|
||||||
} else {
|
} else {
|
||||||
snprintf(mime_mapping, sizeof(mime_mapping), "%s=%s", ext, mime);
|
snprintf(mime_mapping, sizeof(mime_mapping), "%s=%s%s",
|
||||||
|
ext, mime, STR_STARTS_WITH_CONSTANT(mime, "text/") ? "; charset=utf8" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mg_http_serve_opts opts = {
|
struct mg_http_serve_opts opts = {
|
||||||
@@ -526,9 +528,9 @@ void tag(struct mg_connection *nc, struct mg_http_message *hm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tag_req_t *req = parse_tag_request(json);
|
tag_req_t *req = parse_tag_request(json);
|
||||||
cJSON_Delete(json);
|
|
||||||
if (req == NULL) {
|
if (req == NULL) {
|
||||||
LOG_DEBUGF("serve.c", "Could not parse tag request", arg_index);
|
LOG_DEBUGF("serve.c", "Could not parse tag request", arg_index);
|
||||||
|
cJSON_Delete(json);
|
||||||
HTTP_REPLY_BAD_REQUEST
|
HTTP_REPLY_BAD_REQUEST
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -552,6 +554,7 @@ void tag(struct mg_connection *nc, struct mg_http_message *hm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(req);
|
free(req);
|
||||||
|
cJSON_Delete(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
int validate_auth(struct mg_connection *nc, struct mg_http_message *hm) {
|
int validate_auth(struct mg_connection *nc, struct mg_http_message *hm) {
|
||||||
|
|||||||
Reference in New Issue
Block a user