mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -04:00
Expand paths in config (closes #277)
This commit is contained in:
parent
167e207fad
commit
a29d6754e8
@ -9,18 +9,14 @@ class Config
|
|||||||
property port : Int32 = 9000
|
property port : Int32 = 9000
|
||||||
property base_url : String = "/"
|
property base_url : String = "/"
|
||||||
property session_secret : String = "mango-session-secret"
|
property session_secret : String = "mango-session-secret"
|
||||||
property library_path : String = File.expand_path "~/mango/library",
|
property library_path : String = "~/mango/library"
|
||||||
home: true
|
property library_cache_path = "~/mango/library.yml.gz"
|
||||||
property library_cache_path = File.expand_path "~/mango/library.yml.gz",
|
property db_path : String = "~/mango/mango.db"
|
||||||
home: true
|
|
||||||
property db_path : String = File.expand_path "~/mango/mango.db", home: true
|
|
||||||
property scan_interval_minutes : Int32 = 5
|
property scan_interval_minutes : Int32 = 5
|
||||||
property thumbnail_generation_interval_hours : Int32 = 24
|
property thumbnail_generation_interval_hours : Int32 = 24
|
||||||
property log_level : String = "info"
|
property log_level : String = "info"
|
||||||
property upload_path : String = File.expand_path "~/mango/uploads",
|
property upload_path : String = "~/mango/uploads"
|
||||||
home: true
|
property plugin_path : String = "~/mango/plugins"
|
||||||
property plugin_path : String = File.expand_path "~/mango/plugins",
|
|
||||||
home: true
|
|
||||||
property download_timeout_seconds : Int32 = 30
|
property download_timeout_seconds : Int32 = 30
|
||||||
property cache_enabled = false
|
property cache_enabled = false
|
||||||
property cache_size_mbs = 50
|
property cache_size_mbs = 50
|
||||||
@ -59,6 +55,7 @@ class Config
|
|||||||
config = self.from_yaml File.read cfg_path
|
config = self.from_yaml File.read cfg_path
|
||||||
config.path = path
|
config.path = path
|
||||||
config.fill_defaults
|
config.fill_defaults
|
||||||
|
config.expand_paths
|
||||||
config.preprocess
|
config.preprocess
|
||||||
return config
|
return config
|
||||||
end
|
end
|
||||||
@ -67,6 +64,7 @@ class Config
|
|||||||
default = self.allocate
|
default = self.allocate
|
||||||
default.path = path
|
default.path = path
|
||||||
default.fill_defaults
|
default.fill_defaults
|
||||||
|
default.expand_paths
|
||||||
cfg_dir = File.dirname cfg_path
|
cfg_dir = File.dirname cfg_path
|
||||||
unless Dir.exists? cfg_dir
|
unless Dir.exists? cfg_dir
|
||||||
Dir.mkdir_p cfg_dir
|
Dir.mkdir_p cfg_dir
|
||||||
@ -86,6 +84,12 @@ class Config
|
|||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def expand_paths
|
||||||
|
{% for p in %w(library library_cache db upload plugin) %}
|
||||||
|
@{{p.id}}_path = File.expand_path @{{p.id}}_path, home: true
|
||||||
|
{% end %}
|
||||||
|
end
|
||||||
|
|
||||||
def preprocess
|
def preprocess
|
||||||
unless base_url.starts_with? "/"
|
unless base_url.starts_with? "/"
|
||||||
raise "base url (#{base_url}) should start with `/`"
|
raise "base url (#{base_url}) should start with `/`"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user