Commit Graph

18 Commits

Author SHA1 Message Date
9d9491253b refactor: clean up imports, simplify checks, and add SearchDropdown component
- Remove unused using directives across C# and Razor files
- Remove unused IServiceProvider from SettingsRepository
- Simplify null/empty string checks in StatsRepository
- Add null-safe navigation for Albums/Tags in stats queries
- Initialize Asset.Hash default to prevent null refs
- Deduplicate AssetIds in AssetPicker
- Add OnStartedWaiting/OnFinishedWaiting/OnProgressChanged to Job
- Add global SearchDropdown component with keyboard nav
- Fix XML doc param mismatches
2026-07-12 20:47:24 +02:00
5514bf89d9 fix: remove double-count of failed assets in master Done handler
The Interlocked.Increment(ref failedAssets) for Failed subjobs
caused double-counting: a subjob with N/12 failed assets would
add 1 (failed subjob) + 12 (individual assets) = 13, exceeding
the total asset count. Removed the Increment since subjob's
failedAssets is already the accurate per-asset count.
2026-07-10 12:17:50 +02:00
8ad378b649 fix: batch-processing subjobs report correct status on asset failures
Subjobs (SlaveJob) now check failedAssets after processing:
- All failed -> JobStatus.Fail()
- Some failed -> JobStatus.CompleteWithErrors()
- None failed -> JobStatus.Complete()

Also fixed race condition in master Done handler:
- Replaced non-atomic failedAssets += sub.failedAssets
- with Interlocked.Add(ref failedAssets, sub.failedAssets)

Affects: PreviewJob, ThumbnailJob, MetadataJob, PHashJob

Refs #76
2026-07-10 12:05:45 +02:00
7a0b72584c fix: propagate cancellation tokens through linked child job CTS
Replace manual childJobs.ForEach(j => j.Cancel()) with linked
CancellationTokenSources. Master jobs now call LinkParentToken(token)
on each child, so when the master's CTS fires, all children (running
and queued) receive cancellation automatically via their linked token.

Cancelling a master job now:
- Immediately signals all Running children via their linked CTS
- Ensures queued children, when started by JobManager, receive an
  already-cancelled token and bail without processing
- Eliminates the collection-modification-during-ForEach race condition

Affects: PHashJob, ThumbnailJob, PreviewJob, MetadataJob,
FileSystemCrawlJob.
2026-07-08 12:00:27 +02:00
REDCODE
458cf70081 feat: add thousands separators to job status numbers 2026-07-08 02:03:40 +02:00
REDCODE
6c9a608ce6 fix: propagate cancellation to sub-jobs in batch processing jobs
MetadataJob, ThumbnailJob, PreviewJob, and PHashJob previously only
canceled the master job's own token, leaving already-enqueued sub-jobs
running indefinitely. Added child-job tracking with proper cancellation
propagation at both master cancellation exit points, matching the
existing pattern in FileSystemCrawlJob.
2026-07-08 00:20:40 +02:00
2b90a4893e refactor(jobs): flatten PHashJob to batch-based sub-jobs 2026-07-07 12:10:55 +02:00
REDCODE
0d12b45563 feat(jobs): apply batching to PHashJob and MetadataJob
Same batch processing pattern as ThumbnailJob:
- Paginated DB queries (200 per batch) via Count + Skip/Take methods
- Atomic counters with Interlocked.Increment
- Thread.Sleep(100) polling instead of busy-wait
- Added failedAssets tracking to MetadataJob (was missing)
2026-07-07 00:19:08 +02:00
25ac326d7e fix(phash): display child jobs grouped by status
- Refactor PHashJob to match ThumbnailJob's master/sub-job pattern:
  - return after JobStatus.Fail() so failures stay Failed
  - track failedAssets counter, use CompleteWithErrors
  - descriptive sub-job names (pHash for {path})
  - lock-based sub-jobs list for thread safety
- Fix JobTree.razor: re-fetch children when parent still active
  - OnExpanded invalidates _childrenCache if job is Queued/Running/Waiting
- Fix scope leaks in IntegrityCheckJob and JobScheduler.FetchSettings
- Increase JobRecord.Name to VARCHAR(2048) to prevent truncation
- Add debug logging for sub-job completion tracking
2026-07-06 21:33:53 +02:00
4cf29ab4f2 fix: prevent master PHashJob from spinning indefinitely on sub-job completion
- Use Interlocked.Increment with Volatile.Read to fix cross-thread
  visibility of the processed count
- Add await Task.Delay(100) in the wait loop to yield the thread
- Fix inverted cancellation check
2026-07-06 19:08:29 +02:00
eb9f0d14d3 docs: add XML documentation to all public APIs across all projects
Achieves 100% XML doc coverage on non-trivial types with CS1591
enforcement via Directory.Build.props.

Coverage by project:
- Butter: from 6.5% to 100% (DTOs, enums, MIME types)
- Lactose: from ~28% to 100% (controllers, services, repos, jobs, models)
- MilkStream.Client: from ~29% to 100% (all frontend services)

Uses <inheritdoc /> on repository implementations (interfaces
already documented) and full <summary>/<param>/<returns> tags
elsewhere. Enums include member-level docs.
2026-07-06 18:45:21 +02:00
0a9c3ba207 feat: optimize jobs API with pagination, DB persistence, and cleanup
- Split /api/jobs into three endpoints: active roots, paginated past,
  children fetched on expand — reduces response from ~1MB to ~5KB
- Persist completed jobs to PostgreSQL via JobRecord entity + migration
- Add configurable job retention cleanup (hourly timer, default 30 days)
- Fix PHashJob master not persisting (missing Complete() call)
- Add PastJobsResponse DTO to fix case-sensitive JsonElement deserialization
- Refactor JobTree/JobRow for lazy-loaded children via FetchChildren callback
- Handle 401 responses in JwtTokenRefresher with token refresh + retry
- Remove JobChildrenSummary component (replaced by inline parent summary)
2026-07-06 18:17:49 +02:00
8a395da790 feat: set ParentJobId on child jobs for ThumbnailJob, FileSystemCrawlJob, PHashJob 2026-07-06 15:15:08 +02:00
Samuele Lorefice
bd18d8f636 Tasks now fail when they fail. 2025-09-04 20:34:03 +02:00
Samuele Lorefice
3bee6c7939 Strictly enforces calling the correct methods to change the job status, ensuring events are fired correctly 2025-09-04 20:10:05 +02:00
Samuele Lorefice
a170025520 Moved to a compatible pgvector db variant, implemented Thumbnails job 2025-09-04 04:59:15 +02:00
Samuele Lorefice
627239f0a3 Enabled vector extensions 2025-09-04 02:40:29 +02:00
REDCODE
28e53eb31b PHash Job implementation 2025-09-03 23:37:56 +02:00