mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -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 session_secret : String = "mango-session-secret"
|
||||||
property library_path : String = File.expand_path "~/mango/library",
|
property library_path : String = File.expand_path "~/mango/library",
|
||||||
home: true
|
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 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
|
||||||
|
@ -7,26 +7,23 @@ class Library
|
|||||||
use_default
|
use_default
|
||||||
|
|
||||||
def save_instance
|
def save_instance
|
||||||
path = Config.current.library_path
|
path = Config.current.library_cache_path
|
||||||
instance_file_path = File.join path, "library.yml.gz"
|
Logger.debug "Caching library to #{path}"
|
||||||
Logger.debug "Caching library to #{instance_file_path}"
|
|
||||||
|
|
||||||
writer = Compress::Gzip::Writer.new instance_file_path,
|
writer = Compress::Gzip::Writer.new path,
|
||||||
Compress::Gzip::BEST_COMPRESSION
|
Compress::Gzip::BEST_COMPRESSION
|
||||||
writer.write self.to_yaml.to_slice
|
writer.write self.to_yaml.to_slice
|
||||||
writer.close
|
writer.close
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load_instance
|
def self.load_instance
|
||||||
dir = Config.current.library_path
|
path = Config.current.library_cache_path
|
||||||
return unless Dir.exists? dir
|
return unless File.exists? path
|
||||||
instance_file_path = File.join dir, "library.yml.gz"
|
|
||||||
return unless File.exists? instance_file_path
|
|
||||||
|
|
||||||
Logger.debug "Loading cached library from #{instance_file_path}"
|
Logger.debug "Loading cached library from #{path}"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Compress::Gzip::Reader.open instance_file_path do |content|
|
Compress::Gzip::Reader.open path do |content|
|
||||||
@@default = Library.from_yaml content
|
@@default = Library.from_yaml content
|
||||||
end
|
end
|
||||||
Library.default.register_jobs
|
Library.default.register_jobs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user