mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
Make library cache path configurable
This commit is contained in:
parent
6e04e249e7
commit
97168b65d8
@ -11,6 +11,8 @@ class Config
|
||||
property session_secret : String = "mango-session-secret"
|
||||
property library_path : String = File.expand_path "~/mango/library",
|
||||
home: true
|
||||
property library_cache_path = File.expand_path "~/mango/library.yml.cbz",
|
||||
home: true
|
||||
property db_path : String = File.expand_path "~/mango/mango.db", home: true
|
||||
property scan_interval_minutes : Int32 = 5
|
||||
property thumbnail_generation_interval_hours : Int32 = 24
|
||||
|
@ -7,26 +7,23 @@ class Library
|
||||
use_default
|
||||
|
||||
def save_instance
|
||||
path = Config.current.library_path
|
||||
instance_file_path = File.join path, "library.yml.gz"
|
||||
Logger.debug "Caching library to #{instance_file_path}"
|
||||
path = Config.current.library_cache_path
|
||||
Logger.debug "Caching library to #{path}"
|
||||
|
||||
writer = Compress::Gzip::Writer.new instance_file_path,
|
||||
writer = Compress::Gzip::Writer.new path,
|
||||
Compress::Gzip::BEST_COMPRESSION
|
||||
writer.write self.to_yaml.to_slice
|
||||
writer.close
|
||||
end
|
||||
|
||||
def self.load_instance
|
||||
dir = Config.current.library_path
|
||||
return unless Dir.exists? dir
|
||||
instance_file_path = File.join dir, "library.yml.gz"
|
||||
return unless File.exists? instance_file_path
|
||||
path = Config.current.library_cache_path
|
||||
return unless File.exists? path
|
||||
|
||||
Logger.debug "Loading cached library from #{instance_file_path}"
|
||||
Logger.debug "Loading cached library from #{path}"
|
||||
|
||||
begin
|
||||
Compress::Gzip::Reader.open instance_file_path do |content|
|
||||
Compress::Gzip::Reader.open path do |content|
|
||||
@@default = Library.from_yaml content
|
||||
end
|
||||
Library.default.register_jobs
|
||||
|
Loading…
x
Reference in New Issue
Block a user