feat(ingest): 源与目录文件名过滤及钉钉文档导出
- filename_filter_rules table (000035) with source-root and per-directory rows - additive inheritance: source default + every ancestor directory contributes - filename_is_filtered() SQL predicate applied to catalog browsing, subtree counts, change-set diffing, routing fan-out and artifact fetch manifests - fetch_state 'filtered' (CHECK extended); reconcile cancels/restores fetch jobs, retires planned publications and blocks items when rules change - GET/PUT/DELETE /api/v1/filename-filters (Idempotency-Key, normalized extensions) + Settings and Catalog filter editors - failJobSQL no longer swallows the claimed row when the failure projection upserts (fixes spurious 'lease lost' retries) - DingTalk live fetch: adoc/axls now use the export-job pipeline (HTTP 403 from file/download fixed), header-signature downloads supported
This commit is contained in:
@@ -95,6 +95,9 @@ func (handler *Handler) Handle(ctx context.Context, job jobs.Job) error {
|
||||
}
|
||||
manifest, err := handler.store.LoadArtifactFetchManifest(ctx, request.ConnectionID, request.NodeID)
|
||||
if err != nil {
|
||||
if errors.Is(err, ErrManifestFiltered) {
|
||||
return nil
|
||||
}
|
||||
if errors.Is(err, ErrManifestGone) {
|
||||
return jobs.Permanent(jobs.ErrCodeStateConflict, err)
|
||||
}
|
||||
@@ -226,6 +229,7 @@ func (runner *CommandRunner) Run(ctx context.Context, manifest Manifest) (Result
|
||||
}
|
||||
|
||||
var ErrManifestGone = errors.New("artifact fetch manifest is gone")
|
||||
var ErrManifestFiltered = errors.New("artifact fetch excluded by filename filter")
|
||||
|
||||
// limitedWriter captures at most limit bytes of script stderr; full output is
|
||||
// never retained (it could echo source details we do not want in failures).
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package artifactfetch
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"knowledge-governance/internal/jobs"
|
||||
)
|
||||
|
||||
type filteredStore struct{}
|
||||
|
||||
func (filteredStore) LoadArtifactFetchManifest(context.Context, string, string) (Manifest, error) {
|
||||
return Manifest{}, ErrManifestFiltered
|
||||
}
|
||||
func (filteredStore) MarkArtifactFetched(context.Context, string, string, int64, string, string, bool, time.Time) error {
|
||||
return nil
|
||||
}
|
||||
func (filteredStore) MarkArtifactFetchMissing(context.Context, string, string, time.Time) error {
|
||||
return nil
|
||||
}
|
||||
func (filteredStore) MarkArtifactFetchFailed(context.Context, string, string, string, time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type panicRunner struct{}
|
||||
|
||||
func (panicRunner) Run(context.Context, Manifest) (Result, error) {
|
||||
panic("filtered artifacts must not start a source fetch")
|
||||
}
|
||||
|
||||
func TestHandlerCompletesFilteredArtifactWithoutRunningFetcher(t *testing.T) {
|
||||
handler, err := NewHandler(Config{Store: filteredStore{}, Runner: panicRunner{}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
payload, _ := json.Marshal(Request{ConnectionID: "conn-1", NodeID: "node-1", VersionID: "version-1"})
|
||||
if err := handler.Handle(context.Background(), jobs.Job{Payload: payload}); err != nil {
|
||||
t.Fatalf("Handle() error = %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user