Config: Use fixed users folder name in the storage path

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2023-03-14 23:17:12 +01:00
parent fb1744b820
commit cad0ecaa6a
5 changed files with 25 additions and 15 deletions

View file

@ -335,16 +335,16 @@ func (c *Config) UsersPath() string {
return clean.UserPath(c.options.UsersPath)
}
// UsersStoragePath returns the users storage base path.
func (c *Config) UsersStoragePath() string {
return filepath.Join(c.StoragePath(), c.UsersPath())
}
// UsersOriginalsPath returns the users originals base path.
func (c *Config) UsersOriginalsPath() string {
return filepath.Join(c.OriginalsPath(), c.UsersPath())
}
// UsersStoragePath returns the users storage base path.
func (c *Config) UsersStoragePath() string {
return filepath.Join(c.StoragePath(), "users")
}
// UserStoragePath returns the storage path for user assets.
func (c *Config) UserStoragePath(userUid string) string {
if !rnd.IsUID(userUid, 0) {

View file

@ -28,6 +28,16 @@ func TestConfig_UsersPath(t *testing.T) {
assert.Contains(t, c.UsersPath(), "users")
}
func TestConfig_UsersOriginalsPath(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Contains(t, c.UsersOriginalsPath(), "users")
}
func TestConfig_UsersStoragePath(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Contains(t, c.UsersStoragePath(), "users")
}
func TestConfig_UserStoragePath(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, "", c.UserStoragePath(""))

View file

@ -132,6 +132,12 @@ var Flags = CliFlags{
Usage: "maximum resolution of media files in `MEGAPIXELS` (1-900; -1 to disable)",
EnvVar: "PHOTOPRISM_RESOLUTION_LIMIT",
}}, {
Flag: cli.StringFlag{
Name: "users-path",
Usage: "relative `PATH` to create base and upload subdirectories for users",
EnvVar: "PHOTOPRISM_USERS_PATH",
Value: "users",
}}, {
Flag: cli.StringFlag{
Name: "storage-path, s",
Usage: "writable storage `PATH` for sidecar, cache, and database files",
@ -162,12 +168,6 @@ var Flags = CliFlags{
Usage: "relative originals `PATH` to which the files should be imported by default*optional*",
EnvVar: "PHOTOPRISM_IMPORT_DEST",
}}, {
Flag: cli.StringFlag{
Name: "users-path",
Usage: "relative `PATH` to create base and upload subdirectories for users",
EnvVar: "PHOTOPRISM_USERS_PATH",
Value: "users",
}}, {
Flag: cli.StringFlag{
Name: "assets-path, as",
Usage: "assets `PATH` containing static resources like icons, models, and translations",

View file

@ -46,9 +46,9 @@ type Options struct {
OriginalsPath string `yaml:"OriginalsPath" json:"-" flag:"originals-path"`
OriginalsLimit int `yaml:"OriginalsLimit" json:"OriginalsLimit" flag:"originals-limit"`
ResolutionLimit int `yaml:"ResolutionLimit" json:"ResolutionLimit" flag:"resolution-limit"`
UsersPath string `yaml:"UsersPath" json:"-" flag:"users-path"`
StoragePath string `yaml:"StoragePath" json:"-" flag:"storage-path"`
SidecarPath string `yaml:"SidecarPath" json:"-" flag:"sidecar-path"`
UsersPath string `yaml:"UsersPath" json:"-" flag:"users-path"`
BackupPath string `yaml:"BackupPath" json:"-" flag:"backup-path"`
CachePath string `yaml:"CachePath" json:"-" flag:"cache-path"`
ImportPath string `yaml:"ImportPath" json:"-" flag:"import-path"`

View file

@ -56,9 +56,12 @@ func (c *Config) Report() (rows [][]string, cols []string) {
{"originals-path", c.OriginalsPath()},
{"originals-limit", fmt.Sprintf("%d", c.OriginalsLimit())},
{"resolution-limit", fmt.Sprintf("%d", c.ResolutionLimit())},
{"users-path", c.UsersPath()},
{"users-originals-path", c.UsersOriginalsPath()},
// Storage.
{"storage-path", c.StoragePath()},
{"users-storage-path", c.UsersStoragePath()},
{"sidecar-path", c.SidecarPath()},
{"albums-path", c.AlbumsPath()},
{"backup-path", c.BackupPath()},
@ -68,9 +71,6 @@ func (c *Config) Report() (rows [][]string, cols []string) {
{"thumb-cache-path", c.ThumbCachePath()},
{"import-path", c.ImportPath()},
{"import-dest", c.ImportDest()},
{"users-path", c.UsersPath()},
{"users-storage-path", c.UsersStoragePath()},
{"users-originals-path", c.UsersOriginalsPath()},
{"assets-path", c.AssetsPath()},
{"static-path", c.StaticPath()},
{"build-path", c.BuildPath()},