Documentation
¶
Overview ¶
Package postgres is the PostgreSQL DB driver.
Uses jackc/pgx/v5 via the stdlib database/sql interface. Most query implementations mirror the SQLite Store but adapted to use $N placeholders and JSONB column types.
To keep the skeleton compact, this file embeds the pgx-flavoured Store methods only as forwarding shells — the actual SQL bodies live inline here and are functionally identical to the SQLite version with the dialect-specific tweaks. Any TODO marker indicates a path that needs the full pg-specific tuning before going to production.
Index ¶
- type Driver
- type Store
- func (s *Store) AbortUnfinishedSyncRuns(ctx context.Context, errMsg string) (int64, error)
- func (s *Store) ActivateTotp(ctx context.Context, id int64) error
- func (s *Store) AggNodes(ctx context.Context, storageID int64) ([]db.NodeAgg, error)
- func (s *Store) AllNodesForIndex(ctx context.Context) ([]*model.Node, error)
- func (s *Store) AttachStagedUploadTarget(ctx context.Context, id string, nodeID, opID int64) error
- func (s *Store) ClaimAppPluginScheduleItem(ctx context.Context, pluginID int64, key, owner string, now time.Time) (bool, error)
- func (s *Store) ClearTotp(ctx context.Context, id int64) error
- func (s *Store) Close() error
- func (s *Store) CountActiveSessions(ctx context.Context) (int64, error)
- func (s *Store) CountLiveNodesUnder(ctx context.Context, storageID int64, dir string) (int64, error)
- func (s *Store) CountNodesAddedSince(ctx context.Context, storageID int64, since time.Time) (int64, error)
- func (s *Store) CountNodesByStorage(ctx context.Context, storageID int64) (int64, error)
- func (s *Store) CountNodesDeletedSince(ctx context.Context, storageID int64, since time.Time) (int64, error)
- func (s *Store) CountQueueDepth(ctx context.Context) (int64, error)
- func (s *Store) CountRecentlyResolvedReplicaFailures(ctx context.Context, since time.Time) (int64, error)
- func (s *Store) CountSyncConflictsByRun(ctx context.Context, runID int64) (int64, error)
- func (s *Store) CountTotalShares(ctx context.Context) (int64, error)
- func (s *Store) CountTrashedExpired(ctx context.Context, before time.Time) (map[int64]db.TrashTally, error)
- func (s *Store) CountUnresolvedReplicaFailures(ctx context.Context) (int64, error)
- func (s *Store) CountUsers(ctx context.Context) (int64, error)
- func (s *Store) CreateAPIToken(ctx context.Context, t *model.APIToken) (*model.APIToken, error)
- func (s *Store) CreateAppPlugin(ctx context.Context, p *model.AppPlugin) (*model.AppPlugin, error)
- func (s *Store) CreateAppPluginJob(ctx context.Context, j *model.AppPluginJob) error
- func (s *Store) CreateAppPluginSigningKey(ctx context.Context, k *model.AppPluginSigningKey) error
- func (s *Store) CreateChunkedUpload(ctx context.Context, u *model.ChunkedUpload) error
- func (s *Store) CreateFileGrant(ctx context.Context, g *model.FileGrant) (*model.FileGrant, error)
- func (s *Store) CreateNFSExport(ctx context.Context, e *model.NFSExport) (*model.NFSExport, error)
- func (s *Store) CreateNode(ctx context.Context, n *model.Node) (*model.Node, error)
- func (s *Store) CreateNodeComment(ctx context.Context, c *model.NodeComment) (*model.NodeComment, error)
- func (s *Store) CreateNodeVersion(ctx context.Context, v *model.NodeVersion) (*model.NodeVersion, error)
- func (s *Store) CreatePlugin(ctx context.Context, p *model.Plugin) (*model.Plugin, error)
- func (s *Store) CreateProvider(ctx context.Context, p *model.Provider) (*model.Provider, error)
- func (s *Store) CreateReplicaRule(ctx context.Context, in *model.ReplicaRuleInput) (*model.ReplicaRule, error)
- func (s *Store) CreateReplicationTarget(ctx context.Context, rt *model.ReplicationTarget) (*model.ReplicationTarget, error)
- func (s *Store) CreateS3AccessKey(ctx context.Context, k *model.S3AccessKey) (*model.S3AccessKey, error)
- func (s *Store) CreateSSHPublicKey(ctx context.Context, k *model.SSHPublicKey) (*model.SSHPublicKey, error)
- func (s *Store) CreateSession(ctx context.Context, userID int64, token string, expiresAt time.Time, ...) (*model.Session, error)
- func (s *Store) CreateShare(ctx context.Context, sh *model.Share) (*model.Share, error)
- func (s *Store) CreateStagedUpload(ctx context.Context, u *model.StagedUpload) error
- func (s *Store) CreateStorage(ctx context.Context, st *model.Storage) (*model.Storage, error)
- func (s *Store) CreateSyncConflict(ctx context.Context, c *model.SyncConflict) error
- func (s *Store) CreateSyncRun(ctx context.Context, storageID int64, cursorBefore string) (*model.SyncRun, error)
- func (s *Store) CreateTag(ctx context.Context, t *model.Tag) (*model.Tag, error)
- func (s *Store) CreateUser(ctx context.Context, email, hash, role, locale, tz string) (*model.User, error)
- func (s *Store) CreateWebhookTarget(ctx context.Context, t *model.WebhookTarget) (*model.WebhookTarget, error)
- func (s *Store) DeleteAPIToken(ctx context.Context, id int64) error
- func (s *Store) DeleteAppPlugin(ctx context.Context, id int64) error
- func (s *Store) DeleteAppPluginLock(ctx context.Context, storageID int64, pathHash string) error
- func (s *Store) DeleteAppPluginState(ctx context.Context, pluginID, storageID int64, pathHash, key string) error
- func (s *Store) DeleteChunkedUpload(ctx context.Context, id string) error
- func (s *Store) DeleteCustomTheme(ctx context.Context, key string) (bool, error)
- func (s *Store) DeleteExpiredAppPluginLocks(ctx context.Context, now time.Time) (int64, error)
- func (s *Store) DeleteExpiredChunkedUploads(ctx context.Context) error
- func (s *Store) DeleteExpiredSessions(ctx context.Context) error
- func (s *Store) DeleteExpiredShares(ctx context.Context) error
- func (s *Store) DeleteFileGrant(ctx context.Context, id int64) error
- func (s *Store) DeleteNFSExport(ctx context.Context, id, userID int64) error
- func (s *Store) DeleteNodeCommentsByNode(ctx context.Context, nodeID int64) error
- func (s *Store) DeleteNodeVersion(ctx context.Context, id int64) error
- func (s *Store) DeleteOldNodeVersions(ctx context.Context, nodeID int64, keep int) ([]*model.NodeVersion, error)
- func (s *Store) DeletePlugin(ctx context.Context, id int64) error
- func (s *Store) DeleteProvider(ctx context.Context, id int64) error
- func (s *Store) DeleteReplicaRule(ctx context.Context, id int64) error
- func (s *Store) DeleteReplicationTarget(ctx context.Context, id int64) error
- func (s *Store) DeleteS3AccessKey(ctx context.Context, id, userID int64) error
- func (s *Store) DeleteSSHPublicKey(ctx context.Context, id, userID int64) error
- func (s *Store) DeleteSession(ctx context.Context, token string) error
- func (s *Store) DeleteSessionsForUser(ctx context.Context, userID int64, exceptToken string) error
- func (s *Store) DeleteShare(ctx context.Context, id int64) error
- func (s *Store) DeleteStagedUpload(ctx context.Context, id string) error
- func (s *Store) DeleteStorage(ctx context.Context, id int64) error
- func (s *Store) DeleteThumbnail(ctx context.Context, nodeID int64) error
- func (s *Store) DeleteUser(ctx context.Context, id int64) error
- func (s *Store) DeleteUserNodeMeta(ctx context.Context, userID, nodeID int64, key string) error
- func (s *Store) DeleteWebhookTarget(ctx context.Context, id int64) error
- func (s *Store) DestroyAppPluginSigningKey(ctx context.Context, id string) error
- func (s *Store) DueAppPluginScheduleItems(ctx context.Context, now time.Time, limit int) ([]*model.AppPluginScheduleItem, error)
- func (s *Store) ExistingNodeIDs(ctx context.Context, ids []int64) (map[int64]bool, error)
- func (s *Store) FinishAppPluginScheduleItem(ctx context.Context, pluginID int64, key, status, jobID, errMsg string, ...) error
- func (s *Store) FinishSyncRun(ctx context.Context, id int64, cursorAfter string, ...) error
- func (s *Store) GetAPITokenByHash(ctx context.Context, tokenHash string) (*model.APIToken, error)
- func (s *Store) GetAPITokenByID(ctx context.Context, id int64) (*model.APIToken, error)
- func (s *Store) GetAppPlugin(ctx context.Context, id int64) (*model.AppPlugin, error)
- func (s *Store) GetAppPluginByName(ctx context.Context, name string) (*model.AppPlugin, error)
- func (s *Store) GetAppPluginJob(ctx context.Context, id string) (*model.AppPluginJob, error)
- func (s *Store) GetAppPluginLock(ctx context.Context, storageID int64, pathHash string) (*model.AppPluginLock, error)
- func (s *Store) GetAppPluginSealKey(ctx context.Context, tenantID, pluginID int64) (*model.AppPluginSigningKey, error)
- func (s *Store) GetAppPluginSettings(ctx context.Context, pluginID int64) (map[string]string, error)
- func (s *Store) GetAppPluginSigningCA(ctx context.Context, tenantID int64) (*model.AppPluginSigningKey, error)
- func (s *Store) GetAppPluginSigningKey(ctx context.Context, id string) (*model.AppPluginSigningKey, error)
- func (s *Store) GetAppPluginState(ctx context.Context, pluginID, storageID int64, pathHash, key string) (string, bool, error)
- func (s *Store) GetChunkedUpload(ctx context.Context, id string) (*model.ChunkedUpload, error)
- func (s *Store) GetCustomTheme(ctx context.Context, key string) (*model.CustomTheme, error)
- func (s *Store) GetExternalService(ctx context.Context, name string) (*db.ExternalService, error)
- func (s *Store) GetFileGrant(ctx context.Context, id int64) (*model.FileGrant, error)
- func (s *Store) GetLastSyncRun(ctx context.Context, storageID int64) (*model.SyncRun, error)
- func (s *Store) GetLastSyncRunByStatus(ctx context.Context, storageID int64, status string) (*model.SyncRun, error)
- func (s *Store) GetNFSExport(ctx context.Context, tokenHash string) (*model.NFSExport, error)
- func (s *Store) GetNFSExportByID(ctx context.Context, id int64) (*model.NFSExport, error)
- func (s *Store) GetNode(ctx context.Context, id int64) (*model.Node, error)
- func (s *Store) GetNodeByPath(ctx context.Context, storageID int64, hash string) (*model.Node, error)
- func (s *Store) GetNodeByPathIncludingDeleted(ctx context.Context, storageID int64, hash string) (*model.Node, error)
- func (s *Store) GetNodeComment(ctx context.Context, id int64) (*model.NodeComment, error)
- func (s *Store) GetNodeOwner(ctx context.Context, nodeID int64) (*int64, error)
- func (s *Store) GetNodeVersion(ctx context.Context, id int64) (*model.NodeVersion, error)
- func (s *Store) GetNotification(ctx context.Context, id int64) (*model.Notification, error)
- func (s *Store) GetNotificationSettings(ctx context.Context, userID int64) (*model.NotificationSettings, error)
- func (s *Store) GetPlugin(ctx context.Context, id int64) (*model.Plugin, error)
- func (s *Store) GetPluginByName(ctx context.Context, name string) (*model.Plugin, error)
- func (s *Store) GetProvider(ctx context.Context, id int64) (*model.Provider, error)
- func (s *Store) GetProviderByHost(ctx context.Context, host string) (*model.Provider, error)
- func (s *Store) GetProviderBySlug(ctx context.Context, slug string) (*model.Provider, error)
- func (s *Store) GetProviderIDForStorage(ctx context.Context, storageID int64) (int64, bool, error)
- func (s *Store) GetProviderPlan(ctx context.Context, providerID int64) (string, string, string, error)
- func (s *Store) GetReplicaRule(ctx context.Context, id int64) (*model.ReplicaRule, error)
- func (s *Store) GetReplicaSettings(ctx context.Context) (*model.ReplicaSettings, error)
- func (s *Store) GetReplicaStatusReport(ctx context.Context) (*model.ReplicaStatusReport, error)
- func (s *Store) GetReplicationTarget(ctx context.Context, id int64) (*model.ReplicationTarget, error)
- func (s *Store) GetS3AccessKey(ctx context.Context, accessKeyID string) (*model.S3AccessKey, error)
- func (s *Store) GetS3AccessKeyByID(ctx context.Context, id int64) (*model.S3AccessKey, error)
- func (s *Store) GetSSHPublicKey(ctx context.Context, fingerprint string) (*model.SSHPublicKey, error)
- func (s *Store) GetSSHPublicKeyByID(ctx context.Context, id int64) (*model.SSHPublicKey, error)
- func (s *Store) GetSessionByToken(ctx context.Context, token string) (*model.Session, error)
- func (s *Store) GetSessionIDToken(ctx context.Context, token string) (string, error)
- func (s *Store) GetSetting(ctx context.Context, key string) (string, error)
- func (s *Store) GetShareByID(ctx context.Context, id int64) (*model.Share, error)
- func (s *Store) GetShareByToken(ctx context.Context, token string) (*model.Share, error)
- func (s *Store) GetStagedUpload(ctx context.Context, id string) (*model.StagedUpload, error)
- func (s *Store) GetStagedUploadByNode(ctx context.Context, nodeID int64) (*model.StagedUpload, error)
- func (s *Store) GetStorage(ctx context.Context, id int64) (*model.Storage, error)
- func (s *Store) GetStorageByName(ctx context.Context, name string) (*model.Storage, error)
- func (s *Store) GetStorageByUID(ctx context.Context, uid string) (*model.Storage, error)
- func (s *Store) GetSupertenant(ctx context.Context) (*model.Provider, error)
- func (s *Store) GetSyncRun(ctx context.Context, id int64) (*model.SyncRun, error)
- func (s *Store) GetThumbnail(ctx context.Context, nodeID int64) (*model.Thumbnail, error)
- func (s *Store) GetUser(ctx context.Context, id int64) (*model.User, error)
- func (s *Store) GetUserByEmail(ctx context.Context, email string) (*model.User, error)
- func (s *Store) GetUserByProviderEmail(ctx context.Context, providerID int64, email string) (*model.User, error)
- func (s *Store) GetUserByUsername(ctx context.Context, username string) (*model.User, error)
- func (s *Store) GetUserDisplayNames(ctx context.Context, ids []int64) (map[int64]string, error)
- func (s *Store) GetUserNodeMeta(ctx context.Context, userID, nodeID int64, key string) (string, error)
- func (s *Store) GetUserPrefs(ctx context.Context, userID int64, surface string) (string, error)
- func (s *Store) GetUserUsage(ctx context.Context, userID int64) (int64, int64, error)
- func (s *Store) GetUserViewPrefs(ctx context.Context, userID int64) (string, error)
- func (s *Store) GetWebhookTarget(ctx context.Context, id int64) (*model.WebhookTarget, error)
- func (s *Store) HardDeleteNode(ctx context.Context, id int64) error
- func (s *Store) IncrementShareDownload(ctx context.Context, id int64) error
- func (s *Store) IncrementShareUpload(ctx context.Context, id int64, n int) error
- func (s *Store) IncrementShareVisit(ctx context.Context, id int64) error
- func (s *Store) IncrementUserUsage(ctx context.Context, userID int64, delta int64) error
- func (s *Store) InsertAuditEntry(ctx context.Context, e *model.AuditEntry) error
- func (s *Store) InsertNotification(ctx context.Context, n *model.NotificationInput) (int64, error)
- func (s *Store) LinkNodeTags(ctx context.Context, nodeID int64, add, remove []int64) error
- func (s *Store) LinkProviderStorage(ctx context.Context, providerID, storageID int64) error
- func (s *Store) ListAPITokens(ctx context.Context) ([]*model.APIToken, error)
- func (s *Store) ListAPITokensByUser(ctx context.Context, userID int64) ([]*model.APIToken, error)
- func (s *Store) ListAllFileGrants(ctx context.Context) ([]*model.FileGrant, error)
- func (s *Store) ListAllShares(ctx context.Context, creatorID *int64, activeOnly bool, limit, offset int) ([]*db.ShareWithMeta, int64, error)
- func (s *Store) ListAppPluginJobsByOp(ctx context.Context, opIDs []int64) (map[int64]*model.AppPluginJob, error)
- func (s *Store) ListAppPluginLocks(ctx context.Context, storageID int64) ([]*model.AppPluginLock, error)
- func (s *Store) ListAppPluginOverrides(ctx context.Context, pluginID int64) ([]*model.AppPluginOverride, error)
- func (s *Store) ListAppPluginScheduleItems(ctx context.Context, pluginID int64) ([]*model.AppPluginScheduleItem, error)
- func (s *Store) ListAppPluginShares(ctx context.Context, pluginID int64, activeOnly bool, limit, offset int) ([]*db.ShareWithMeta, int64, error)
- func (s *Store) ListAppPluginSigningCAs(ctx context.Context, tenantID int64) ([]*model.AppPluginSigningKey, error)
- func (s *Store) ListAppPluginStateFiles(ctx context.Context, pluginID int64, key string, limit int) ([]*model.AppPluginStateFile, error)
- func (s *Store) ListAppPluginStateKeys(ctx context.Context, storageID int64, pathHashes []string) (map[string][]string, error)
- func (s *Store) ListAppPlugins(ctx context.Context) ([]*model.AppPlugin, error)
- func (s *Store) ListAuditFiltered(ctx context.Context, userID *int64, action string, from, to *time.Time, ...) ([]*db.AuditEntryWithUser, int64, error)
- func (s *Store) ListAuditRecent(ctx context.Context, limit int) ([]*model.AuditEntry, error)
- func (s *Store) ListConflictsByStorage(ctx context.Context, storageID int64, limit int) ([]*model.SyncConflict, error)
- func (s *Store) ListCustomThemes(ctx context.Context) ([]*model.CustomTheme, error)
- func (s *Store) ListDuplicateNodes(ctx context.Context, minSize int64) ([]db.DuplicateNode, error)
- func (s *Store) ListEnabledStorages(ctx context.Context) ([]*model.Storage, error)
- func (s *Store) ListExternalServices(ctx context.Context) ([]*db.ExternalService, error)
- func (s *Store) ListFileGrantsByStorage(ctx context.Context, storageID int64) ([]*model.FileGrant, error)
- func (s *Store) ListFileGrantsByStorageUser(ctx context.Context, storageID, userID int64) ([]*model.FileGrant, error)
- func (s *Store) ListIdleStagedUploads(ctx context.Context, before time.Time, limit int) ([]*model.StagedUpload, error)
- func (s *Store) ListLiveNodesInTrash(ctx context.Context, storageID int64, trashPrefix string) ([]*model.Node, error)
- func (s *Store) ListNFSExports(ctx context.Context, userID int64) ([]*model.NFSExport, error)
- func (s *Store) ListNodeComments(ctx context.Context, nodeID int64) ([]*model.NodeComment, error)
- func (s *Store) ListNodeIDsWithVersions(ctx context.Context) ([]int64, error)
- func (s *Store) ListNodeTags(ctx context.Context, nodeID int64) ([]*model.Tag, error)
- func (s *Store) ListNodeVersions(ctx context.Context, nodeID int64) ([]*model.NodeVersion, error)
- func (s *Store) ListNodesByParent(ctx context.Context, storageID int64, parentID *int64) ([]*model.Node, error)
- func (s *Store) ListNodesByTagIDs(ctx context.Context, tagIDs []int64, limit int) ([]*model.Node, error)
- func (s *Store) ListNodesByUserMeta(ctx context.Context, userID int64, key string, limit int) ([]*model.Node, error)
- func (s *Store) ListNodesUnder(ctx context.Context, storageID int64, dir string, includeDeleted bool) ([]*model.Node, error)
- func (s *Store) ListNotifications(ctx context.Context, userID *int64, onlyUnread bool, ...) ([]*model.Notification, int64, error)
- func (s *Store) ListPlugins(ctx context.Context) ([]*model.Plugin, error)
- func (s *Store) ListProviderStorageIDs(ctx context.Context, providerID int64) ([]int64, error)
- func (s *Store) ListProviders(ctx context.Context) ([]*model.Provider, error)
- func (s *Store) ListReplicaFailures(ctx context.Context, onlyUnresolved bool, limit, offset int) ([]*model.ReplicaFailure, int64, error)
- func (s *Store) ListReplicaRules(ctx context.Context) ([]*model.ReplicaRule, error)
- func (s *Store) ListReplicationTargets(ctx context.Context) ([]*model.ReplicationTarget, error)
- func (s *Store) ListS3AccessKeys(ctx context.Context, userID int64) ([]*model.S3AccessKey, error)
- func (s *Store) ListSSHPublicKeys(ctx context.Context, userID int64) ([]*model.SSHPublicKey, error)
- func (s *Store) ListSettings(ctx context.Context) (map[string]string, error)
- func (s *Store) ListSharesByNode(ctx context.Context, nodeID int64) ([]*model.Share, error)
- func (s *Store) ListStagedUploads(ctx context.Context, state string, limit int) ([]*model.StagedUpload, error)
- func (s *Store) ListStaleNodes(ctx context.Context, storageID int64, before time.Time) ([]*model.Node, error)
- func (s *Store) ListStaleNodesUnder(ctx context.Context, storageID int64, dir string, before time.Time) ([]*model.Node, error)
- func (s *Store) ListStorages(ctx context.Context) ([]*model.Storage, error)
- func (s *Store) ListSyncConflictsByRun(ctx context.Context, runID int64) ([]*model.SyncConflict, error)
- func (s *Store) ListSyncConflictsByStorage(ctx context.Context, storageID int64, limit int) ([]*model.SyncConflict, error)
- func (s *Store) ListSyncRuns(ctx context.Context, storageID int64, limit int) ([]*model.SyncRun, error)
- func (s *Store) ListSyncRunsAcrossAll(ctx context.Context, storageID int64, status string, limit, offset int) ([]*model.SyncRun, int64, error)
- func (s *Store) ListTagPlacements(ctx context.Context, q model.TagQuery) ([]model.TagPlacement, error)
- func (s *Store) ListTags(ctx context.Context, q model.TagQuery) ([]*model.Tag, error)
- func (s *Store) ListTrashed(ctx context.Context, storageID *int64, limit, offset int) ([]*model.Node, int, error)
- func (s *Store) ListTrashedExpired(ctx context.Context, before time.Time, storageIDs []int64, afterID int64, ...) ([]*model.Node, error)
- func (s *Store) ListUnresolvedConflicts(ctx context.Context) ([]*model.SyncConflict, error)
- func (s *Store) ListUnstoredNodes(ctx context.Context, afterID int64, limit int) ([]*model.Node, error)
- func (s *Store) ListUserNodeMetaForNode(ctx context.Context, userID, nodeID int64, prefix string) (map[string]string, error)
- func (s *Store) ListUsers(ctx context.Context) ([]*model.User, error)
- func (s *Store) ListUsersByProvider(ctx context.Context, providerID int64) ([]*model.User, error)
- func (s *Store) ListWebhookTargets(ctx context.Context) ([]*model.WebhookTarget, error)
- func (s *Store) LookupParentByPath(ctx context.Context, storageID int64, fullPath string) (*int64, error)
- func (s *Store) MarkAllBroadcastsRead(ctx context.Context, readerID int64) error
- func (s *Store) MarkAllNotificationsRead(ctx context.Context, userID *int64) error
- func (s *Store) MarkBroadcastsRead(ctx context.Context, readerID int64, ids []int64) error
- func (s *Store) MarkNotificationRead(ctx context.Context, id int64, userID *int64) error
- func (s *Store) MoveNode(ctx context.Context, id int64, parentID *int64, name, path, hash string) error
- func (s *Store) NextAppPluginScheduleDue(ctx context.Context) (*time.Time, error)
- func (s *Store) NextNodeVersionNumber(ctx context.Context, nodeID int64) (int, error)
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) PutAppPluginLock(ctx context.Context, l *model.AppPluginLock) error
- func (s *Store) PutAppPluginOverrides(ctx context.Context, pluginID int64, list []*model.AppPluginOverride) error
- func (s *Store) PutAppPluginScheduleItem(ctx context.Context, it *model.AppPluginScheduleItem) error
- func (s *Store) PutAppPluginSettings(ctx context.Context, pluginID int64, values map[string]string) error
- func (s *Store) ReapAppPluginScheduleItems(ctx context.Context, before time.Time) (int64, error)
- func (s *Store) RecomputeUserUsage(ctx context.Context, userID int64) (int64, error)
- func (s *Store) ReleaseShareDownload(ctx context.Context, id int64) error
- func (s *Store) ReserveShareDownload(ctx context.Context, id int64) (bool, error)
- func (s *Store) ResolveConflict(ctx context.Context, id int64, resolution string) error
- func (s *Store) ResolveReplicaFailure(ctx context.Context, path, op string) error
- func (s *Store) RestoreNode(ctx context.Context, id int64) error
- func (s *Store) RestoreNodeAt(ctx context.Context, id int64, parentID *int64, origPath string) error
- func (s *Store) RetireAppPluginSigningCA(ctx context.Context, tenantID int64) error
- func (s *Store) RevokeShare(ctx context.Context, id int64) error
- func (s *Store) SearchNodes(ctx context.Context, storageID int64, m model.NameMatch, limit int) ([]*model.Node, error)
- func (s *Store) SetAppPluginJobOp(ctx context.Context, jobID string, opID int64) error
- func (s *Store) SetAppPluginState(ctx context.Context, pluginID, storageID int64, ...) error
- func (s *Store) SetNFSExportDisabled(ctx context.Context, id int64, disabled bool) error
- func (s *Store) SetNodeActor(ctx context.Context, nodeID int64, actorID *int64) error
- func (s *Store) SetNodeExternalUpload(ctx context.Context, nodeID int64, external bool) error
- func (s *Store) SetNodeMtime(ctx context.Context, id int64, mtime *time.Time) error
- func (s *Store) SetNodeOwner(ctx context.Context, nodeID int64, ownerID *int64) error
- func (s *Store) SetNodeSize(ctx context.Context, id int64, size int64) error
- func (s *Store) SetNodeTransferState(ctx context.Context, nodeID int64, state string) error
- func (s *Store) SetProviderPlan(ctx context.Context, providerID int64, plan, limitsJSON, billingRef string) error
- func (s *Store) SetS3AccessKeyDisabled(ctx context.Context, id int64, disabled bool) error
- func (s *Store) SetSSHPublicKeyDisabled(ctx context.Context, id int64, disabled bool) error
- func (s *Store) SetSessionIDToken(ctx context.Context, token, idToken string) error
- func (s *Store) SetThumbnailState(ctx context.Context, nodeID int64, state, errMsg string) error
- func (s *Store) SetTotpPendingSecret(ctx context.Context, id int64, secret string, recoveryCodes []string) error
- func (s *Store) SetUserEnabled(ctx context.Context, userID int64, enabled bool) error
- func (s *Store) SetUserNodeMeta(ctx context.Context, userID, nodeID int64, key, value string) error
- func (s *Store) SetUserPrefs(ctx context.Context, userID int64, surface, doc string) error
- func (s *Store) SetUserProvider(ctx context.Context, userID, providerID int64, oidcSubject string) error
- func (s *Store) SetUserQuota(ctx context.Context, userID int64, bytes int64) error
- func (s *Store) SetUserUsername(ctx context.Context, id int64, username string) error
- func (s *Store) SetUserViewPrefs(ctx context.Context, userID int64, doc string) error
- func (s *Store) SoftDeleteAndRetag(ctx context.Context, id int64, trashPath, trashHash, origPath string) error
- func (s *Store) SoftDeleteNode(ctx context.Context, id int64) error
- func (s *Store) SoftDeleteNodeComment(ctx context.Context, id int64) error
- func (s *Store) StorageStats(ctx context.Context, storageID int64) (int64, int64, error)
- func (s *Store) SumNodesBytesByStorage(ctx context.Context, storageID int64) (int64, error)
- func (s *Store) SumOpenStagedUploadBytes(ctx context.Context, userID int64) (int64, error)
- func (s *Store) TouchAPIToken(ctx context.Context, id int64) error
- func (s *Store) TouchLastLogin(ctx context.Context, id int64) error
- func (s *Store) TouchNFSExport(ctx context.Context, id int64) error
- func (s *Store) TouchNodeSeen(ctx context.Context, id int64) error
- func (s *Store) TouchS3AccessKey(ctx context.Context, id int64) error
- func (s *Store) TouchSSHPublicKey(ctx context.Context, id int64) error
- func (s *Store) UnlinkProviderStorage(ctx context.Context, providerID, storageID int64) error
- func (s *Store) UnreadNotificationCount(ctx context.Context, userID *int64, mutedEvents, hiddenBodies []string, ...) (int64, error)
- func (s *Store) UpdateAPITokenMeta(ctx context.Context, id int64, label, usernames, kind *string) error
- func (s *Store) UpdateAppPlugin(ctx context.Context, p *model.AppPlugin) error
- func (s *Store) UpdateAppPluginJob(ctx context.Context, j *model.AppPluginJob) error
- func (s *Store) UpdateChunkedUploadParts(ctx context.Context, id string, parts []model.UploadPart) error
- func (s *Store) UpdateExternalServiceState(ctx context.Context, name string, lastCheck time.Time, state string) error
- func (s *Store) UpdateFileGrantLevel(ctx context.Context, id int64, level string) error
- func (s *Store) UpdateNodeMeta(ctx context.Context, id int64, size int64, mime, etag string, mtime time.Time) error
- func (s *Store) UpdatePlugin(ctx context.Context, p *model.Plugin) error
- func (s *Store) UpdateProvider(ctx context.Context, p *model.Provider) error
- func (s *Store) UpdateReplicaRule(ctx context.Context, id int64, in *model.ReplicaRuleInput) (*model.ReplicaRule, error)
- func (s *Store) UpdateReplicationTarget(ctx context.Context, rt *model.ReplicationTarget) error
- func (s *Store) UpdateShareAppState(ctx context.Context, id int64, stateJSON string) error
- func (s *Store) UpdateSharePinLock(ctx context.Context, id int64, fails int, until *time.Time) error
- func (s *Store) UpdateStagedUploadProgress(ctx context.Context, id string, receivedBytes int64) error
- func (s *Store) UpdateStagedUploadState(ctx context.Context, id, state, errMsg string) error
- func (s *Store) UpdateStorage(ctx context.Context, st *model.Storage) error
- func (s *Store) UpdateStorageSyncCursor(ctx context.Context, id int64, at time.Time, token string) error
- func (s *Store) UpdateUserAvatar(ctx context.Context, id int64, avatarURL string) error
- func (s *Store) UpdateUserDisplayName(ctx context.Context, id int64, displayName string) error
- func (s *Store) UpdateUserEmail(ctx context.Context, id int64, email string) error
- func (s *Store) UpdateUserLocale(ctx context.Context, id int64, locale, tz string) error
- func (s *Store) UpdateUserPassword(ctx context.Context, id int64, hash string) error
- func (s *Store) UpdateUserRole(ctx context.Context, id int64, role string) error
- func (s *Store) UpdateWebhookStatus(ctx context.Context, id int64, status, errMsg string) error
- func (s *Store) UpdateWebhookTarget(ctx context.Context, t *model.WebhookTarget) error
- func (s *Store) UpdateWebhookTargetDelivery(ctx context.Context, id int64, httpStatus int, errMsg string, at time.Time) error
- func (s *Store) UpsertCustomTheme(ctx context.Context, t *model.CustomTheme) error
- func (s *Store) UpsertExternalService(ctx context.Context, name string, enabled bool, ...) error
- func (s *Store) UpsertNotificationSettings(ctx context.Context, st *model.NotificationSettings) error
- func (s *Store) UpsertReplicaFailure(ctx context.Context, path, op, errCode, errMsg string) error
- func (s *Store) UpsertReplicaSettings(ctx context.Context, st *model.ReplicaSettings) error
- func (s *Store) UpsertReplicaStatusReport(ctx context.Context, total, failed, repaired int64, summaryJSON []byte) error
- func (s *Store) UpsertSetting(ctx context.Context, key, value string) error
- func (s *Store) UpsertThumbnail(ctx context.Context, t *model.Thumbnail) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct{}
Driver implements db.Driver for Postgres.
func (Driver) MigrationsFS ¶
MigrationsFS returns the embedded Postgres migrations.
type Store ¶
type Store struct {
// The catalogue_folders methods (internal/db catalogue_folders_sql.go).
*db.CatalogueFolderSQL
// contains filtered or unexported fields
}
Store implements db.Store atop Postgres.
NOTE: This is a stub for the parts of the surface that have non-trivial dialect-specific quirks. The methods that already work cleanly with $N substitution are filled in; the rest delegate to TODOs that callers will recognize.
func (*Store) AbortUnfinishedSyncRuns ¶
func (*Store) ActivateTotp ¶
ActivateTotp moves the pending secret into totp_secret and flips totp_enabled.
func (*Store) AllNodesForIndex ¶
AllNodesForIndex returns every non-deleted node for the search rebuild job.
func (*Store) AttachStagedUploadTarget ¶
func (*Store) ClaimAppPluginScheduleItem ¶
func (*Store) CountActiveSessions ¶
CountActiveSessions counts non-expired sessions.
func (*Store) CountLiveNodesUnder ¶
func (*Store) CountNodesAddedSince ¶
func (s *Store) CountNodesAddedSince(ctx context.Context, storageID int64, since time.Time) (int64, error)
CountNodesAddedSince counts non-deleted nodes created in the given window.
func (*Store) CountNodesByStorage ¶
func (*Store) CountNodesDeletedSince ¶
func (s *Store) CountNodesDeletedSince(ctx context.Context, storageID int64, since time.Time) (int64, error)
CountNodesDeletedSince counts soft-deleted nodes in the given window.
func (*Store) CountQueueDepth ¶
CountQueueDepth returns the number of running sync_runs.
func (*Store) CountRecentlyResolvedReplicaFailures ¶
func (s *Store) CountRecentlyResolvedReplicaFailures(ctx context.Context, since time.Time) (int64, error)
CountRecentlyResolvedReplicaFailures counts rows resolved since the given time.
func (*Store) CountSyncConflictsByRun ¶
CountSyncConflictsByRun counts conflicts within a run's time window.
func (*Store) CountTotalShares ¶
CountTotalShares returns the number of currently-active shares.
func (*Store) CountTrashedExpired ¶
func (s *Store) CountTrashedExpired(ctx context.Context, before time.Time) (map[int64]db.TrashTally, error)
CountTrashedExpired tallies per storage what ListTrashedExpired walks for the same cutoff.
⚠ SUM(bigint) is NUMERIC here, which will not scan into an int64: cast it.
func (*Store) CountUnresolvedReplicaFailures ¶
CountUnresolvedReplicaFailures returns the unresolved count.
func (*Store) CreateAPIToken ¶
func (*Store) CreateAppPlugin ¶
func (*Store) CreateAppPluginJob ¶
func (*Store) CreateAppPluginSigningKey ¶
func (*Store) CreateChunkedUpload ¶
func (*Store) CreateFileGrant ¶
func (*Store) CreateNFSExport ¶
func (*Store) CreateNode ¶
func (*Store) CreateNodeComment ¶
func (s *Store) CreateNodeComment(ctx context.Context, c *model.NodeComment) (*model.NodeComment, error)
CreateNodeComment inserts a comment row and returns the stored row (with id + timestamps filled in). Body validation (length, emptiness) belongs to internal/comments — the store persists what it is given.
func (*Store) CreateNodeVersion ¶
func (s *Store) CreateNodeVersion(ctx context.Context, v *model.NodeVersion) (*model.NodeVersion, error)
func (*Store) CreatePlugin ¶
func (*Store) CreateProvider ¶
func (*Store) CreateReplicaRule ¶
func (s *Store) CreateReplicaRule(ctx context.Context, in *model.ReplicaRuleInput) (*model.ReplicaRule, error)
CreateReplicaRule inserts a new rule.
func (*Store) CreateReplicationTarget ¶
func (s *Store) CreateReplicationTarget(ctx context.Context, rt *model.ReplicationTarget) (*model.ReplicationTarget, error)
func (*Store) CreateS3AccessKey ¶
func (s *Store) CreateS3AccessKey(ctx context.Context, k *model.S3AccessKey) (*model.S3AccessKey, error)
func (*Store) CreateSSHPublicKey ¶
func (s *Store) CreateSSHPublicKey(ctx context.Context, k *model.SSHPublicKey) (*model.SSHPublicKey, error)
func (*Store) CreateSession ¶
func (*Store) CreateShare ¶
func (*Store) CreateStagedUpload ¶
func (*Store) CreateStorage ¶
func (*Store) CreateSyncConflict ¶
func (*Store) CreateSyncRun ¶
func (*Store) CreateUser ¶
func (*Store) CreateWebhookTarget ¶
func (s *Store) CreateWebhookTarget(ctx context.Context, t *model.WebhookTarget) (*model.WebhookTarget, error)
CreateWebhookTarget inserts a new delivery destination and returns the stored row (with id + created_at filled in).
func (*Store) DeleteAppPlugin ¶
func (*Store) DeleteAppPluginLock ¶
func (*Store) DeleteAppPluginState ¶
func (*Store) DeleteChunkedUpload ¶
func (*Store) DeleteCustomTheme ¶
DeleteCustomTheme removes a theme, reporting whether a row was there.
func (*Store) DeleteExpiredAppPluginLocks ¶
func (*Store) DeleteExpiredChunkedUploads ¶
func (*Store) DeleteExpiredSessions ¶
func (*Store) DeleteFileGrant ¶
func (*Store) DeleteNFSExport ¶
DeleteNFSExport takes the owner id too — see the sqlite driver.
func (*Store) DeleteNodeCommentsByNode ¶
DeleteNodeCommentsByNode hard-deletes every comment row of a node — the trash purge hook (belt and suspenders next to the nodes FK CASCADE).
func (*Store) DeleteNodeVersion ¶
DeleteNodeVersion removes a single version row.
func (*Store) DeleteOldNodeVersions ¶
func (s *Store) DeleteOldNodeVersions(ctx context.Context, nodeID int64, keep int) ([]*model.NodeVersion, error)
DeleteOldNodeVersions deletes all but the newest `keep` versions for a node. Returns the rows that were removed.
func (*Store) DeleteReplicaRule ¶
DeleteReplicaRule removes a rule.
func (*Store) DeleteReplicationTarget ¶
func (*Store) DeleteS3AccessKey ¶
DeleteS3AccessKey takes the owner id too — see the sqlite driver.
func (*Store) DeleteSSHPublicKey ¶
DeleteSSHPublicKey takes the owner id too — see the sqlite driver.
func (*Store) DeleteSession ¶
func (*Store) DeleteSessionsForUser ¶
DeleteSessionsForUser revokes all sessions for a user, optionally keeping `exceptToken` (the current session) alive.
func (*Store) DeleteStagedUpload ¶
func (*Store) DeleteThumbnail ¶
func (*Store) DeleteUserNodeMeta ¶
DeleteUserNodeMeta removes a single (user, node, key) row.
func (*Store) DeleteWebhookTarget ¶
DeleteWebhookTarget removes a target row.
func (*Store) DestroyAppPluginSigningKey ¶
func (*Store) DueAppPluginScheduleItems ¶
func (*Store) ExistingNodeIDs ¶
ExistingNodeIDs batches the lookup so a large thumbnail cache cannot exceed the 65535-parameter ceiling of the extended protocol.
func (*Store) FinishAppPluginScheduleItem ¶
func (*Store) FinishSyncRun ¶
func (*Store) GetAPITokenByHash ¶
func (*Store) GetAPITokenByID ¶
GetAPITokenByID fetches a token by primary key — see the sqlite driver.
func (*Store) GetAppPlugin ¶
func (*Store) GetAppPluginByName ¶
func (*Store) GetAppPluginJob ¶
func (*Store) GetAppPluginLock ¶
func (*Store) GetAppPluginSealKey ¶
func (*Store) GetAppPluginSettings ¶
func (*Store) GetAppPluginSigningCA ¶
func (*Store) GetAppPluginSigningKey ¶
func (*Store) GetAppPluginState ¶
func (*Store) GetChunkedUpload ¶
func (*Store) GetCustomTheme ¶
GetCustomTheme returns one theme by slug, or (nil, nil) when there is none.
func (*Store) GetExternalService ¶
func (*Store) GetFileGrant ¶
func (*Store) GetLastSyncRun ¶
func (*Store) GetLastSyncRunByStatus ¶
func (*Store) GetNFSExport ¶
GetNFSExport is the mount path: one indexed read on the hashed secret.
func (*Store) GetNFSExportByID ¶
func (*Store) GetNodeByPath ¶
func (*Store) GetNodeByPathIncludingDeleted ¶
func (s *Store) GetNodeByPathIncludingDeleted(ctx context.Context, storageID int64, hash string) (*model.Node, error)
GetNodeByPathIncludingDeleted returns the row at a path, live or trashed.
⚠ ORDER BY is load-bearing since migration 00032 made the unique index over (storage_id, path_hash) live-only: several trashed rows may now share a path with at most one live one. The live row sorts first, then the most recently trashed. Without it the sync worker's view of a path would depend on row order.
func (*Store) GetNodeComment ¶
GetNodeComment returns a single live (not soft-deleted) comment by id.
func (*Store) GetNodeOwner ¶
GetNodeOwner returns the owner_id (nullable) for one node.
func (*Store) GetNodeVersion ¶
GetNodeVersion looks up a single version row by id.
func (*Store) GetNotification ¶
GetNotification returns a single row by id.
func (*Store) GetNotificationSettings ¶
func (s *Store) GetNotificationSettings(ctx context.Context, userID int64) (*model.NotificationSettings, error)
GetNotificationSettings returns the per-user toggle (default-on when no row exists).
func (*Store) GetPluginByName ¶
func (*Store) GetProvider ¶
func (*Store) GetProviderByHost ¶
func (*Store) GetProviderBySlug ¶
func (*Store) GetProviderIDForStorage ¶
func (*Store) GetProviderPlan ¶
func (*Store) GetReplicaRule ¶
GetReplicaRule returns a single rule by id.
func (*Store) GetReplicaSettings ¶
GetReplicaSettings returns the singleton row.
func (*Store) GetReplicaStatusReport ¶
GetReplicaStatusReport returns the singleton row.
func (*Store) GetReplicationTarget ¶
func (*Store) GetS3AccessKey ¶
GetS3AccessKey is the hot path: every signed request looks its key up here, so it is a single indexed read and nothing more.
func (*Store) GetS3AccessKeyByID ¶
func (*Store) GetSSHPublicKey ¶
func (s *Store) GetSSHPublicKey(ctx context.Context, fingerprint string) (*model.SSHPublicKey, error)
GetSSHPublicKey is the login path: one indexed read on the fingerprint.
func (*Store) GetSSHPublicKeyByID ¶
func (*Store) GetSessionByToken ¶
func (*Store) GetSessionIDToken ¶
GetSessionIDToken implements db.Store — see the SQLite store for the rules.
func (*Store) GetSetting ¶
func (*Store) GetShareByID ¶
GetShareByID looks up a share by its row ID.
func (*Store) GetShareByToken ¶
func (*Store) GetStagedUpload ¶
func (*Store) GetStagedUploadByNode ¶
func (*Store) GetStorage ¶
func (*Store) GetStorageByName ¶
func (*Store) GetStorageByUID ¶
func (*Store) GetSupertenant ¶
func (*Store) GetSyncRun ¶
GetSyncRun looks up a sync_run by id.
func (*Store) GetThumbnail ¶
func (*Store) GetUserByEmail ¶
func (*Store) GetUserByProviderEmail ¶
func (*Store) GetUserByUsername ¶
GetUserByUsername is the username half of dual-side login (migration 00025). Callers should reach it through identity.Resolve rather than directly, so the e-mail/username disambiguation lives in one place.
func (*Store) GetUserDisplayNames ¶
GetUserDisplayNames — see the sqlite driver for why this returns names and not users.
func (*Store) GetUserNodeMeta ¶
func (s *Store) GetUserNodeMeta(ctx context.Context, userID, nodeID int64, key string) (string, error)
GetUserNodeMeta fetches a single value (returns empty string + sql.ErrNoRows if absent).
func (*Store) GetUserPrefs ¶
GetUserPrefs returns the raw JSON document for one person on one surface, or "" when there is none. No row and an empty column are one answer; neither is an error.
func (*Store) GetUserUsage ¶
GetUserUsage returns (used_bytes, quota_bytes).
func (*Store) GetUserViewPrefs ¶
GetUserViewPrefs returns the raw JSON document for a user, or "" when there is none. No row and an empty column are one answer; neither is an error.
func (*Store) GetWebhookTarget ¶
GetWebhookTarget returns a single target by id.
func (*Store) IncrementShareDownload ¶
func (*Store) IncrementShareUpload ¶
func (*Store) IncrementShareVisit ¶
IncrementShareVisit counts one opening of an app page (00052): what the page's `max_visits` ceiling is measured against, and never a download.
func (*Store) IncrementUserUsage ¶
IncrementUserUsage atomically adjusts usage_bytes (delta may be negative).
func (*Store) InsertAuditEntry ¶
func (*Store) InsertNotification ¶
InsertNotification persists a new in-app notification row. The payload mirrors the SQLite implementation but uses $N placeholders and JSONB casting on meta_json.
func (*Store) LinkNodeTags ¶
LinkNodeTags implements db.Store.
func (*Store) LinkProviderStorage ¶
func (*Store) ListAPITokens ¶
func (*Store) ListAPITokensByUser ¶
func (*Store) ListAllFileGrants ¶
func (*Store) ListAllShares ¶
func (s *Store) ListAllShares(ctx context.Context, creatorID *int64, activeOnly bool, limit, offset int) ([]*db.ShareWithMeta, int64, error)
ListAllShares returns the admin overview of every share. `creatorID` nil means all users; activeOnly excludes expired/revoked rows.
func (*Store) ListAppPluginJobsByOp ¶
func (*Store) ListAppPluginLocks ¶
func (*Store) ListAppPluginOverrides ¶
func (*Store) ListAppPluginScheduleItems ¶
func (*Store) ListAppPluginShares ¶
func (s *Store) ListAppPluginShares(ctx context.Context, pluginID int64, activeOnly bool, limit, offset int) ([]*db.ShareWithMeta, int64, error)
ListAppPluginShares is the admin view of the links APPS opened. pluginID 0 means every app; it never means every share (that is ListAllShares).
func (*Store) ListAppPluginSigningCAs ¶
func (*Store) ListAppPluginStateFiles ¶
func (*Store) ListAppPluginStateKeys ¶
func (*Store) ListAppPlugins ¶
func (*Store) ListAuditFiltered ¶
func (s *Store) ListAuditFiltered(ctx context.Context, userID *int64, action string, from, to *time.Time, limit, offset int) ([]*db.AuditEntryWithUser, int64, error)
ListAuditFiltered returns paginated audit entries with user_email join + filters.
func (*Store) ListAuditRecent ¶
func (*Store) ListConflictsByStorage ¶
func (s *Store) ListConflictsByStorage(ctx context.Context, storageID int64, limit int) ([]*model.SyncConflict, error)
ListConflictsByStorage returns recent sync conflicts for one storage.
func (*Store) ListCustomThemes ¶
ListCustomThemes returns every stored theme, oldest first.
func (*Store) ListDuplicateNodes ¶
ListDuplicateNodes returns every live file node whose (size, non-empty etag) pair occurs more than once — the raw rows behind the admin duplicate report. Mirrors the SQLite driver with $N placeholders.
func (*Store) ListEnabledStorages ¶
func (*Store) ListExternalServices ¶
func (*Store) ListFileGrantsByStorage ¶
func (*Store) ListFileGrantsByStorageUser ¶
func (*Store) ListIdleStagedUploads ¶
func (*Store) ListLiveNodesInTrash ¶
func (s *Store) ListLiveNodesInTrash(ctx context.Context, storageID int64, trashPrefix string) ([]*model.Node, error)
ListLiveNodesInTrash returns live rows sitting in the trash bucket. See the db.Store declaration for why any such row is a defect to be cleaned up.
func (*Store) ListNFSExports ¶
func (*Store) ListNodeComments ¶
ListNodeComments returns the live comments of one node in chronological order (oldest first), each carrying the author's display name (falling back to the author's email).
func (*Store) ListNodeIDsWithVersions ¶
ListNodeIDsWithVersions returns the distinct node ids holding at least one version row — the work list for the daily retention job.
func (*Store) ListNodeTags ¶
ListNodeTags implements db.Store.
func (*Store) ListNodeVersions ¶
func (*Store) ListNodesByParent ¶
func (*Store) ListNodesByTagIDs ¶
func (s *Store) ListNodesByTagIDs(ctx context.Context, tagIDs []int64, limit int) ([]*model.Node, error)
ListNodesByTagIDs implements db.Store.
func (*Store) ListNodesByUserMeta ¶
func (s *Store) ListNodesByUserMeta(ctx context.Context, userID int64, key string, limit int) ([]*model.Node, error)
ListNodesByUserMeta returns the nodes flagged with (key) for the given user.
func (*Store) ListNodesUnder ¶
func (*Store) ListNotifications ¶
func (s *Store) ListNotifications(ctx context.Context, userID *int64, onlyUnread bool, mutedEvents, hiddenBodies []string, broadcasts model.BroadcastFilter, limit, offset int) ([]*model.Notification, int64, error)
ListNotifications paginates either user or admin views. onlyUnread keeps the rows still unread for the reader; mutedEvents drops the event ids the user has muted, empty means no mute filter; hiddenBodies drops rows whose body matches one of the LIKE patterns; broadcasts decides which broadcasts the bell takes at all and whose read state they carry (see db.Store).
func (*Store) ListPlugins ¶
func (*Store) ListProviderStorageIDs ¶
func (*Store) ListProviders ¶
func (*Store) ListReplicaFailures ¶
func (s *Store) ListReplicaFailures(ctx context.Context, onlyUnresolved bool, limit, offset int) ([]*model.ReplicaFailure, int64, error)
ListReplicaFailures paginates rows.
func (*Store) ListReplicaRules ¶
ListReplicaRules returns the rule list ordered priority asc.
func (*Store) ListReplicationTargets ¶
func (*Store) ListS3AccessKeys ¶
func (*Store) ListSSHPublicKeys ¶
func (*Store) ListSettings ¶
func (*Store) ListSharesByNode ¶
func (*Store) ListStagedUploads ¶
func (*Store) ListStaleNodes ¶
func (*Store) ListStaleNodesUnder ¶
func (*Store) ListStorages ¶
func (*Store) ListSyncConflictsByRun ¶
func (s *Store) ListSyncConflictsByRun(ctx context.Context, runID int64) ([]*model.SyncConflict, error)
ListSyncConflictsByRun returns conflicts attributed to a specific sync_run.
func (*Store) ListSyncConflictsByStorage ¶
func (s *Store) ListSyncConflictsByStorage(ctx context.Context, storageID int64, limit int) ([]*model.SyncConflict, error)
ListSyncConflictsByStorage returns recent unresolved conflicts.
func (*Store) ListSyncRuns ¶
func (*Store) ListSyncRunsAcrossAll ¶
func (s *Store) ListSyncRunsAcrossAll(ctx context.Context, storageID int64, status string, limit, offset int) ([]*model.SyncRun, int64, error)
ListSyncRunsAcrossAll returns paginated runs across every storage. storageID==0 means "all", status=="" means "all".
func (*Store) ListTagPlacements ¶
func (s *Store) ListTagPlacements(ctx context.Context, q model.TagQuery) ([]model.TagPlacement, error)
ListTagPlacements implements db.Store.
func (*Store) ListTrashed ¶
func (s *Store) ListTrashed(ctx context.Context, storageID *int64, limit, offset int) ([]*model.Node, int, error)
ListTrashed returns paginated soft-deleted rows (storage filter optional).
func (*Store) ListTrashedExpired ¶
func (s *Store) ListTrashedExpired(ctx context.Context, before time.Time, storageIDs []int64, afterID int64, limit int) ([]*model.Node, error)
ListTrashedExpired returns soft-deleted nodes whose deleted_at is older than `before`, in id order after `afterID`, narrowed to storageIDs (see db.Store for why the id, and why the narrowing is in the SQL).
func (*Store) ListUnresolvedConflicts ¶
func (*Store) ListUnstoredNodes ¶
func (*Store) ListUserNodeMetaForNode ¶
func (s *Store) ListUserNodeMetaForNode(ctx context.Context, userID, nodeID int64, prefix string) (map[string]string, error)
ListUserNodeMetaForNode returns all (key,value) for one (user,node) pair.
func (*Store) ListUsersByProvider ¶
func (*Store) ListWebhookTargets ¶
ListWebhookTargets returns every target ordered by id. Enabled/event filtering happens in the notify dispatcher, not in SQL — the table is tiny and the admin list needs disabled rows too.
func (*Store) LookupParentByPath ¶
func (s *Store) LookupParentByPath(ctx context.Context, storageID int64, fullPath string) (*int64, error)
LookupParentByPath walks the cache one segment at a time to resolve the parent_id (nil at root) for the dir that owns `fullPath`.
func (*Store) MarkAllBroadcastsRead ¶
MarkAllBroadcastsRead moves readerID's "mark all read" point to the newest notification — never backwards — and drops the single marks it overtook.
func (*Store) MarkAllNotificationsRead ¶
MarkAllNotificationsRead bumps read_at for every unread row addressed to userID — never a broadcast, see MarkNotificationRead. Pass nil for the global "mark all" admin sweep.
func (*Store) MarkBroadcastsRead ¶
MarkBroadcastsRead records readerID's marks on the given broadcasts, in one statement per batch: only ids that are broadcasts nobody stamped through the shared column get a mark, and a mark that exists already is left alone.
func (*Store) MarkNotificationRead ¶
MarkNotificationRead bumps read_at on a single row. With a userID the row must be ADDRESSED to that user: a broadcast is many readers' row and is marked per reader by MarkBroadcastsRead.
func (*Store) MoveNode ¶
func (s *Store) MoveNode(ctx context.Context, id int64, parentID *int64, name, path, hash string) error
MoveNode re-homes a node: new parent, name, path and path hash — and, for a LIVE row, the storage_key that must mirror that path.
⚠ storage_key is not decoration. It is what internal/versioning, the antivirus quarantine, the id-addressed download (`Manager.Read`) and the sync tombstone pass hand to the driver as the file's key, each of them preferring it over `path`. Leaving it at the pre-move value made every one of those address a path the file no longer occupies, and every one of them fails SILENTLY on a miss: the snapshot before an overwrite records nothing and lets the write through, the quarantine reports success while the infected bytes stay live, `confirmGone` tombstones a file that is fine, and a download by id 404s on a file the listing shows.
⚠⚠ The CASE is the trash exception and it is load-bearing. On a trashed row storage_key deliberately holds the ORIGINAL path (SoftDeleteAndRetag writes it) — that is the only record of where trash.Service.Restore has to put the file back, and sync.reconcileTrash reads it to tell a restorable deletion from a row that has to be hard-deleted. Overwriting it here would destroy both. Live rows mirror path; trashed rows keep their origin.
func (*Store) NextAppPluginScheduleDue ¶
func (*Store) NextNodeVersionNumber ¶
NextNodeVersionNumber returns COALESCE(MAX(version_n),0)+1 for a node.
func (*Store) PutAppPluginLock ¶
func (*Store) PutAppPluginOverrides ¶
func (*Store) PutAppPluginScheduleItem ¶
func (s *Store) PutAppPluginScheduleItem(ctx context.Context, it *model.AppPluginScheduleItem) error
PutAppPluginScheduleItem writes the item, leaving a RUNNING row alone: the process holding that lease owns it and will finish it.
func (*Store) PutAppPluginSettings ¶
func (*Store) ReapAppPluginScheduleItems ¶
func (*Store) RecomputeUserUsage ¶
RecomputeUserUsage scans the file nodes owned by this user, sets usage_bytes.
⚠ TRASHED ROWS ARE INCLUDED — no `deleted_at IS NULL`, deliberately. See the SQLite driver's copy for the full reasoning; in short, trashed bytes still count and the purge is the only release point (docs/QUOTAS.md).
func (*Store) ReleaseShareDownload ¶
ReleaseShareDownload hands a reserved slot back, never below zero.
func (*Store) ReserveShareDownload ¶
ReserveShareDownload claims one download against the cap in a single statement, so overlapping requests cannot all pass a check that each of them read before any of them wrote. False = the cap is already spent.
func (*Store) ResolveConflict ¶
func (*Store) ResolveReplicaFailure ¶
ResolveReplicaFailure stamps resolved_at on the matching row.
func (*Store) RestoreNode ¶
RestoreNode flips deleted_at back to NULL.
func (*Store) RestoreNodeAt ¶
func (s *Store) RestoreNodeAt(ctx context.Context, id int64, parentID *int64, origPath string) error
RestoreNodeAt flips deleted_at and reverts the path/parent in one shot. Trashed directories also revive the descendants dragged in with them (SoftDeleteAndRetag mirror).
func (*Store) RetireAppPluginSigningCA ¶
func (*Store) RevokeShare ¶
RevokeShare soft-revokes by setting expires_at = NOW (audit trail intact).
func (*Store) SearchNodes ¶
func (*Store) SetAppPluginJobOp ¶
func (*Store) SetAppPluginState ¶
func (*Store) SetNFSExportDisabled ¶
func (*Store) SetNodeActor ¶
SetNodeActor updates the last_actor_id column for one node. nil is SYSTEM.
func (*Store) SetNodeExternalUpload ¶
SetNodeExternalUpload marks a node as having arrived through an anonymous drop link.
func (*Store) SetNodeMtime ¶
func (*Store) SetNodeOwner ¶
SetNodeOwner updates the owner_id column for one node.
func (*Store) SetNodeSize ¶
func (*Store) SetNodeTransferState ¶
func (*Store) SetProviderPlan ¶
func (*Store) SetS3AccessKeyDisabled ¶
func (*Store) SetSSHPublicKeyDisabled ¶
func (*Store) SetSessionIDToken ¶
SetSessionIDToken implements db.Store (migration 00057).
func (*Store) SetThumbnailState ¶
func (*Store) SetTotpPendingSecret ¶
func (s *Store) SetTotpPendingSecret(ctx context.Context, id int64, secret string, recoveryCodes []string) error
SetTotpPendingSecret stores a freshly-enrolled TOTP secret + recovery codes prior to the user verifying with a one-time code.
func (*Store) SetUserEnabled ¶
SetUserEnabled flips the account on/off. Files, quota and grants are untouched -- this is an access switch, not a soft delete.
func (*Store) SetUserNodeMeta ¶
SetUserNodeMeta upserts a (user, node, key) row.
func (*Store) SetUserPrefs ¶
SetUserPrefs replaces the whole document for one person on one surface.
func (*Store) SetUserProvider ¶
func (*Store) SetUserQuota ¶
SetUserQuota writes the quota_bytes value (0 = unlimited).
func (*Store) SetUserUsername ¶
SetUserUsername claims a login name. The unique index — not any check above this call — is what actually guarantees uniqueness, so a caller racing another creation gets an error here and is expected to try another name.
func (*Store) SetUserViewPrefs ¶
SetUserViewPrefs replaces the whole document for a user.
func (*Store) SoftDeleteAndRetag ¶
func (s *Store) SoftDeleteAndRetag(ctx context.Context, id int64, trashPath, trashHash, origPath string) error
SoftDeleteAndRetag — see store.go interface for semantics.
Directories drag their cached subtree into the trash with them (GitHub issue #5) — see the sqlite driver's SoftDeleteAndRetag doc comment.
func (*Store) SoftDeleteNodeComment ¶
SoftDeleteNodeComment flips deleted_at on a live comment.
func (*Store) StorageStats ¶
func (*Store) SumNodesBytesByStorage ¶
SumNodesBytesByStorage returns the total size in bytes of non-deleted files for one storage.
func (*Store) SumOpenStagedUploadBytes ¶
func (*Store) TouchS3AccessKey ¶
func (*Store) TouchSSHPublicKey ¶
func (*Store) UnlinkProviderStorage ¶
func (*Store) UnreadNotificationCount ¶
func (s *Store) UnreadNotificationCount(ctx context.Context, userID *int64, mutedEvents, hiddenBodies []string, broadcasts model.BroadcastFilter) (int64, error)
UnreadNotificationCount returns the bell badge number for a user.
func (*Store) UpdateAPITokenMeta ¶
func (s *Store) UpdateAPITokenMeta(ctx context.Context, id int64, label, usernames, kind *string) error
UpdateAPITokenMeta edits label, the username allow-list and/or the token kind. nil = keep.
func (*Store) UpdateAppPlugin ¶
func (*Store) UpdateAppPluginJob ¶
func (*Store) UpdateChunkedUploadParts ¶
func (*Store) UpdateExternalServiceState ¶
func (*Store) UpdateFileGrantLevel ¶
func (*Store) UpdateNodeMeta ¶
func (*Store) UpdatePlugin ¶
func (*Store) UpdateProvider ¶
func (*Store) UpdateReplicaRule ¶
func (s *Store) UpdateReplicaRule(ctx context.Context, id int64, in *model.ReplicaRuleInput) (*model.ReplicaRule, error)
UpdateReplicaRule replaces a rule by id.
func (*Store) UpdateReplicationTarget ¶
func (*Store) UpdateShareAppState ¶
UpdateShareAppState replaces the plugin's durable record for one link.
func (*Store) UpdateSharePinLock ¶
func (s *Store) UpdateSharePinLock(ctx context.Context, id int64, fails int, until *time.Time) error
UpdateSharePinLock writes the strike counter and the lock deadline and NOTHING else — a wrong PIN must not be able to move an expiry or a cap.
func (*Store) UpdateStagedUploadProgress ¶
func (*Store) UpdateStagedUploadState ¶
func (*Store) UpdateStorage ¶
func (*Store) UpdateStorageSyncCursor ¶
func (*Store) UpdateUserAvatar ¶
UpdateUserAvatar stores (or, with an empty string, clears) the profile picture. Validation of the URI belongs to the API layer, which is the only place that knows what a browser will accept.
func (*Store) UpdateUserDisplayName ¶
UpdateUserDisplayName sets the user's human-friendly display name.
func (*Store) UpdateUserEmail ¶
UpdateUserEmail changes a user's email address.
func (*Store) UpdateUserLocale ¶
func (*Store) UpdateUserPassword ¶
func (*Store) UpdateUserRole ¶
func (*Store) UpdateWebhookStatus ¶
UpdateWebhookStatus updates the delivery audit fields.
func (*Store) UpdateWebhookTarget ¶
UpdateWebhookTarget replaces the mutable columns of a target row.
func (*Store) UpdateWebhookTargetDelivery ¶
func (s *Store) UpdateWebhookTargetDelivery(ctx context.Context, id int64, httpStatus int, errMsg string, at time.Time) error
UpdateWebhookTargetDelivery records the newest delivery outcome (migration 00019). errMsg "" (success) stores NULL in last_error.
func (*Store) UpsertCustomTheme ¶
UpsertCustomTheme creates or replaces a theme, keyed on its slug.
func (*Store) UpsertExternalService ¶
func (*Store) UpsertNotificationSettings ¶
func (s *Store) UpsertNotificationSettings(ctx context.Context, st *model.NotificationSettings) error
UpsertNotificationSettings stores the user's preferences via INSERT ... ON CONFLICT.
func (*Store) UpsertReplicaFailure ¶
UpsertReplicaFailure inserts or bumps the (path, op) row.
func (*Store) UpsertReplicaSettings ¶
UpsertReplicaSettings replaces (id=1) the singleton config.
func (*Store) UpsertReplicaStatusReport ¶
func (s *Store) UpsertReplicaStatusReport(ctx context.Context, total, failed, repaired int64, summaryJSON []byte) error
UpsertReplicaStatusReport replaces (id=1) the singleton report.