[ '--config-skel', '-k', GetoptLong::REQUIRED_ARGUMENT, _("Filename where the script will output a config skeleton") ],
[ '--merge-config', '-M', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, where to merge new images/videos from --source, and change theme info") ],
[ '--merge-config-onedir', '-O', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, for merging the subdir specified with --dir") ],
- [ '--dir', '-D', GetoptLong::REQUIRED_ARGUMENT, _("Directory for merge with --merge-config-onedir") ],
+ [ '--merge-config-subdirs', '-U', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, for merging the new subdirs down the subdir specified with --dir") ],
+ [ '--dir', '-D', GetoptLong::REQUIRED_ARGUMENT, _("Directory for merge with --merge-config-onedir or --merge-config-subdirs") ],
[ '--use-config', '-u', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, where to change theme info") ],
[ '--force', '-f', GetoptLong::NO_ARGUMENT, _("Force generation of album even if the GUI marked some directories as already generated") ],
else
die _('Config file does not exist or is unreadable.')
end
+ when '--merge-config-subdirs'
+ arg = File.expand_path(arg)
+ if File.readable?(arg)
+ msg 2, _("Merge config notice: backuping current config file to %s.backup") % arg
+ $xmldoc = REXML::Document.new File.new(arg)
+ File.rename(arg, "#{arg}.backup")
+ $config_writeto = arg
+ $mode = 'merge_config_subdirs'
+ else
+ die _('Config file does not exist or is unreadable.')
+ end
when '--dir'
arg = File.expand_path(arg)
if !File.readable?(arg)
end
if $mode == 'merge_config_onedir' && !$onedir
- die _("Missing --dir for --merge_config_onedir")
+ die _("Missing --dir for --merge-config-onedir")
+ end
+ if $mode == 'merge_config_subdirs' && !$onedir
+ die _("Missing --dir for --merge-config-subdirs")
end
if !$source
#- preprocess the path->dir, rexml is very slow with that; we seem to improve speed by 7%
optxpath = {}
$xmldoc.elements.each('//dir') { |elem|
+ puts "setting up path: #{elem.attributes['path']}"
optxpath[elem.attributes['path']] = elem
}
- examined_dirs = $mode == 'merge_config_onedir' ? [ $onedir ] : `find '#{$source}' -type d -follow`.sort
+ examined_dirs = nil
+ if $mode == 'merge_config_onedir'
+ examined_dirs = [ $onedir ]
+ elsif $mode == 'merge_config_subdirs'
+ examined_dirs = `find '#{$onedir}' -type d -follow`.sort.collect { |v| v.chomp }.delete_if { |v| optxpath.has_key?(utf8(v)) }
+ else
+ examined_dirs = `find '#{$source}' -type d -follow`.sort
+ end
info("directories: #{examined_dirs.length}, sizes: #{$images_size.length}")
examined_dirs.each { |dir|
next
end
else
- if $mode == 'gen_config' || ($mode == 'merge_config' && !xmldir)
+ if $mode == 'gen_config' || (($mode == 'merge_config' || $mode == 'merge_config_subdirs') && !xmldir)
#- add the <dir..> element if necessary
parent = File.dirname(dir)
xmldir = $xmldoc.elements["//dir[@path='#{utf8(parent)}']"]