This commit is contained in:
onysd 2026-08-25 00:51:43 +03:00
parent ddaef7454a
commit 2cfc7a0539
3 changed files with 34 additions and 3 deletions

View file

@ -89,6 +89,13 @@ type Service struct {
premiumPromoReady bool
gifCatalog store.GifCatalogStore
// gifSeedDir is cfg.GifSeedDir, the same root SeedGifs scans at startup.
// AdminDeleteUncategorizedGifs needs it too: a seed-imported entry's
// underlying file still sits in this directory, and SeedGifs re-imports
// any file there without a matching gif_catalog row on the very next
// restart -- deleting only the DB row would make a "deleted" GIF come
// back on its own.
gifSeedDir string
}
// Option 配置 files 服务的可选能力。
@ -180,6 +187,16 @@ func WithGifCatalog(c store.GifCatalogStore) Option {
}
}
// WithGifSeedDir records the gif seed directory (cfg.GifSeedDir) so
// AdminDeleteUncategorizedGifs can remove a seed-imported entry's source
// file alongside its DB row -- see the field's doc comment for why that
// matters.
func WithGifSeedDir(dir string) Option {
return func(s *Service) {
s.gifSeedDir = dir
}
}
// NewService 创建 files 服务。dc 是本 server 的 DC id,写入新建 document/photo 的 dc_id。
func NewService(media store.MediaStore, blobs BlobBackend, dc int, opts ...Option) *Service {
s := &Service{