feat(settings,index): per-user index sub-path, strip dead PP settings, scope duplicates
Lets a user pick a sub-folder under their library as a working index root, stored server-side (new sidecar user_prefs table). The Library tree, reindex, and both duplicate views (stacks + cross-folder scan) now re-root to it via a single userLibraryBase() helper. Also fixes the cross-folder scan/archive endpoints, which previously walked/touched the whole originals root instead of being scoped per-user (archive now rejects out-of-scope paths, 403). Removes PhotoPrism settings (Search/Maps/Server-UI/Features/Import) that only steered PhotoPrism's own bundled SPA and were never read by mulimage's UI. Also fixes the Library tree occasionally getting stuck on "Loading folders…" by dropping gcTime:0 and gating the spinner on isLoading instead of isPending. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,21 @@ type Mark struct {
|
||||
// nothing surprising lands in the schema.
|
||||
func (Mark) TableName() string { return "marks" }
|
||||
|
||||
// UserPref holds the per-user, server-side preferences PhotoPrism's account
|
||||
// model has no slot for. Today that's just `IndexPath` — the originals-
|
||||
// relative sub-folder (under the user's BasePath) the web client re-roots the
|
||||
// Library tree to and scopes the reindex to. Empty string = "whole folder".
|
||||
// Keyed by username so each user has independent prefs, matching `Mark`.
|
||||
type UserPref struct {
|
||||
UserName string `gorm:"primaryKey;size:128;column:user_name" json:"-"`
|
||||
IndexPath string `gorm:"size:1024;column:index_path" json:"indexPath"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
|
||||
}
|
||||
|
||||
// TableName pins the table name (GORM would pluralise to `user_prefs` anyway,
|
||||
// but pin it explicitly to stay consistent with Mark).
|
||||
func (UserPref) TableName() string { return "user_prefs" }
|
||||
|
||||
// asJSON returns the wire shape clients expect — same flat object the
|
||||
// Node prototype emitted. An empty Mark (rating=nil, color=nil) renders
|
||||
// as `{}` which the client treats as "no mark on this photo".
|
||||
@@ -56,7 +71,7 @@ func openDB(dsn string) (*gorm.DB, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.AutoMigrate(&Mark{}); err != nil {
|
||||
if err := db.AutoMigrate(&Mark{}, &UserPref{}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return db, nil
|
||||
|
||||
Reference in New Issue
Block a user